Sonar Scanner for Jenkins in a Jenkinsfile, "pending" status stucks the pipeline

6,336 views
Skip to first unread message

Idan Adar

unread,
Mar 30, 2017, 11:22:10 AM3/30/17
to SonarQube
Hi,

In this stage, if status is "pending", the pipeline gets stuck in this stage until you have to abort the pipeline...
Is there a way to produce more logs?

The stage:
script {
   withSonarQubeEnv
('SonarQube') {
      sh
"../../../sonar-scanner-2.9.0.670/bin/sonar-scanner"  
   
}
   
   
def qualitygate = waitForQualityGate()
   
if (qualitygate.status != "OK") {
      error
"Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
   
}
}

The log:

Checking status of SonarQube task 'AVsfmCBrxGDonPx3ACVN' on server 'SonarQube'
SonarQube task 'AVsfmCBrxGDonPx3ACVN' status is 'PENDING'

Also, this typically happens if a leak in the coverage has occurred.
The quality gate can be seen in the attached image.

It's set to 10% because we're not yet ready to enforce it on the developers :) but what's even more interesting is that this happens in a repository that is almost at 100% anyway...
Screen Shot 2017-03-30 at 18.19.53.png

Duarte Meneses

unread,
Apr 5, 2017, 10:48:28 AM4/5/17
to SonarQube
Hi,

What is the version of the SonarQube server?

Idan Adar

unread,
Apr 5, 2017, 12:16:57 PM4/5/17
to Duarte Meneses, SonarQube
6.3

Sent from my iPhone
--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/oJ-aqaTJgWg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/8102e774-e7eb-4239-8d33-6864e3247bf1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Julien HENRY

unread,
Apr 10, 2017, 1:13:37 PM4/10/17
to SonarQube
Hi,

Have you correctly configured the webhook in SonarQube server to notify Jenkins when quality gate status is updated?

++

Julien

Idan Adar

unread,
Apr 10, 2017, 5:22:45 PM4/10/17
to Julien HENRY, SonarQube
Can you define "correctly"?

Sent from my iPhone
--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/oJ-aqaTJgWg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+...@googlegroups.com.

Julien HENRY

unread,
Apr 10, 2017, 6:18:03 PM4/10/17
to Idan Adar, SonarQube
Do you have a trailing "slash" in the URL as mentioned in the documentation?
Is the Jenkins URL reachable from the SonarQube server?
Can you have a look at Jenkins and SonarQube server logs. On Jenkins side you should see a message when a payload is received, and on SonarQube side, an error may be logged if the webhook can't reach the destination.

BTW, what is your SonarQube server version?

To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.

Idan Adar

unread,
Apr 10, 2017, 11:33:56 PM4/10/17
to Julien HENRY, SonarQube
6.3. 

As mentioned, please keep in mind that sonar is working most of the time but we did experience some cases that when the status is "pending" it gets stuck... so the configuration is valid because it mostly works. 

Sent from my iPhone

Julien HENRY

unread,
Apr 11, 2017, 2:44:20 AM4/11/17
to Idan Adar, SonarQube
The fact it is mostly working is not a guarantee that the webhook configuration is valid. The step waitForQualityGate starts by a direct call to SonarQube WS to check that status is not already completed (and so webhook payload may have been already sent before the waitForQualityGate step was actually registered to listen for it).

The log you see in build logs is an evidence of this first direct call. If the result is already available, then the step ends without relying on the webhook.

Please look at Jenkins server logs (global logs) to see if the payload is correctly received.

Julien HENRY

unread,
Apr 12, 2017, 2:47:52 AM4/12/17
to Idan Adar, SonarQube
2017-04-12 6:41 GMT+02:00 Idan Adar <id...@adar.me>:
> Do you have a trailing "slash" in the URL as mentioned in the documentation? 

The URL is: http://***:9000/sonarqube
So, no trailing slash...

Here I'm talking of the URL you put in the webhook configuration. So this is something like http://your.jenkins.server/sonarqube-webhook/
 

> Is the Jenkins URL reachable from the SonarQube server?

It has to be, otherwise nothing would've worked no?

Again, when the waitForQualityGate step starts, it does a single Jenkins -> SonarQube WS call. When this call is done, if analysis is already completed on SonarQube side, then the webhook will not be used. So having it working "sometimes" is not a proof that the SonarQube -> Jenkins way is working.
 

> Can you have a look at Jenkins and SonarQube server logs. On Jenkins side you should see a message when a payload is received, and on SonarQube side, an error may be logged if the webhook can't reach the destination.

The next time it happens...


Julien HENRY

unread,
Apr 12, 2017, 3:01:41 AM4/12/17
to Idan Adar, SonarQube
(Please respond also to the list)

When Jenkins receive a webhook, it will log (in Jenkins main logs, not in the build logs) something like:
Received POST from your.sonarqube.server

2017-04-12 8:56 GMT+02:00 Idan Adar <id...@adar.me>:
In SonarQube > Administration > Webhooks I do have a trailing slash: 
http://****/sonarqube-webhook/

How can I verify the webhook is working properly? 
--
Idan Adar

ramesh.th...@gmail.com

unread,
Dec 28, 2017, 7:25:59 AM12/28/17
to SonarQube
Hello,

I had similar issue. For me, I have solved it by updating the webhook URL in SonarQube from "http://jenkinshost:jenkinsport/sonarqube-webhook/" to "http://jenkinsuser:jenkinspassword@jenkinshost:jenkinsport/sonarqube-webhook/". 

Basically the username and password of jenkins is required. While appending the credentials this way in the URL sounds insecure (SonarQube admin can see Jenkins password), it basically solved the issue for me.

Regards,
Ramesh
Reply all
Reply to author
Forward
0 new messages