Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Sonar Scanner Failure Condition #4437

MFalkner ·

Sonar Scanner "Failure Condition" seems to have no effect.

The documentation shows "return !current.passed;" for this field.
The default is "return current.passed".

However, whether I use "return false;" or "return true;", the step always fails.
Also, I cannot find the Quality Gate Result as shown in the documentation.

What is the correct way of using this step?

  • solved #13
  • replies 12
  • views 273
  • stars 0
martin57 ·

I also use it in this way and I do not know whether it should be used this way or not, if someone knows the answer, I would ask

steveluo ADMIN ·
MFalkner ·

Unfortunately, I do not see any change.
It does not matter whether I return true or false in the 'Failure Condition', the step fails anyway.

steveluo ADMIN ·

Hi@MFalkner

Are there any error reports in the build log or server log?

Are there any errors can be found on SonarQube server? And any errors reported from SonarQube webhook deliveries?

sonar-side-webhook.png

I also want to confirm that:

  • You are testing with QB V12.0.14
  • The failure condition is: return !current.passed
  • The SonarQube params are set properly, including host, project and token
  • The webhook for SonarQube and QuickBuild are also set properly.

Below is the command line I used to make sure SonarQube is working correctly from my shell:

sonar-command.png

and below is the settings form my Sonar Scanner Step:

sonar-step.png

and my webhook for SonarQube:

sonar-webhook.png
MFalkner ·

Hi@steveluo,
Yes, I'm running version V12.0.14.
I assumed, if the failure condition is set to return false, it should always pass. Isn't this the case?
And yes, the build does not pass the quality gate, however, to see the result in Quickbuild, I thought I just return false for the failure condition as the description states:

True means step is failed, false means step is successful
BTW: I also tried true, without any change.

18:49:41,288 INFO - INFO: ------------- Check Quality Gate status
18:49:41,288 INFO - INFO: Waiting for the analysis report to be processed (max 600s)
18:53:37,265 INFO - INFO: ------------------------------------------------------------------------
18:53:37,265 INFO - INFO: EXECUTION FAILURE
18:53:37,265 INFO - INFO: ------------------------------------------------------------------------
18:53:37,265 INFO - INFO: Total time: 9:27.008s
18:53:37,363 INFO - INFO: Final Memory: 97M/334M
18:53:37,363 INFO - INFO: ------------------------------------------------------------------------
18:53:37,364 ERROR - ERROR: Error during SonarScanner execution
18:53:37,364 ERROR - ERROR: QUALITY GATE STATUS: FAILED - View details on http://xxxx:9000/dashboard?id=GPR3-APP

My intention was to always pass the step (as SonarQube successfully analyzed), and have the result presented as described in:

Was this a wrong assumption?

Also, what is wrong with this case?

18:40:26,047 INFO - 18:40:26.047 INFO: Waiting for the analysis report to be processed (max 600s)
18:40:26,058 INFO - 18:40:26.058 DEBUG: GET 200 http://xxxx:9000/api/ce/task?id=ABCDEFGHIJKLMNOPQRST | time=11ms
18:40:31,083 INFO - 18:40:31.083 DEBUG: GET 200 http://xxxx:9000/api/ce/task?id=ABCDEFGHIJKLMNOPQRST | time=12ms
18:40:36,105 INFO - 18:40:36.105 DEBUG: GET 200 http://xxxx:9000/api/ce/task?id=ABCDEFGHIJKLMNOPQRST | time=10ms
18:40:41,121 INFO - 18:40:41.121 DEBUG: GET 200 http://xxxx:9000/api/ce/task?id=ABCDEFGHIJKLMNOPQRST | time=9ms
18:40:46,145 INFO - 18:40:46.145 DEBUG: GET 200 http://xxxx:9000/api/ce/task?id=ABCDEFGHIJKLMNOPQRST | time=10ms
18:40:51,184 INFO - 18:40:51.184 DEBUG: GET 200 http://xxxx:9000/api/ce/task?id=ABCDEFGHIJKLMNOPQRST | time=28ms
18:40:51,195 INFO - 18:40:51.195 DEBUG: GET 200 http://xxxx:9000/api/qualitygates/project_status?analysisId=ABCDEFG-_ZX82 | time=10ms
18:40:51,204 INFO - 18:40:51.204 INFO: QUALITY GATE STATUS: PASSED - View details on http://xxxx:9000/dashboard?id=HAL-FwLoaders
18:40:51,208 INFO - 18:40:51.208 DEBUG: Post-jobs :
18:40:51,279 INFO - 18:40:51.279 INFO: Analysis total time: 3:39.892 s
18:40:51,285 INFO - 18:40:51.285 INFO: ------------------------------------------------------------------------
18:40:51,285 INFO - 18:40:51.285 INFO: EXECUTION SUCCESS
18:40:51,285 INFO - 18:40:51.285 INFO: ------------------------------------------------------------------------
18:40:51,285 INFO - 18:40:51.285 INFO: Total time: 3:41.921s
18:40:51,373 INFO - 18:40:51.373 INFO: Final Memory: 40M/137M
18:40:51,373 INFO - 18:40:51.373 INFO: ------------------------------------------------------------------------
18:40:51,940 INFO - Waiting for Sonar Quality Gate ...
18:40:51,940 INFO - Trying to load sonar conditions report from server ...
18:41:01,951 INFO - Trying to load sonar conditions report from server ...
18:41:21,960 INFO - Trying to load sonar conditions report from server ...
18:41:51,972 INFO - Trying to load sonar conditions report from server ...
18:42:31,982 INFO - Trying to load sonar conditions report from server ...
18:43:21,995 INFO - Trying to load sonar conditions report from server ...
18:44:22,005 INFO - Trying to load sonar conditions report from server ...
18:45:32,014 INFO - Trying to load sonar conditions report from server ...
18:46:52,024 INFO - Trying to load sonar conditions report from server ...
18:48:22,034 INFO - Trying to load sonar conditions report from server ...
18:48:22,043 INFO - Executing post-execute action...
18:48:22,043 ERROR - Step 'master>Builds for SonarCube?VSVersion=2019>SonarCube Parallel>SonarCube?SonarOutput=E:\DailyBuild\SER_SONARQUBE\sonar-HAL-FwLoaders>Build SonarCube' is failed: Wait for Quality Gate failed.

steveluo ADMIN ·

@MFalkner

Yes, return false should always pass the step. But in your case, it seems that you are using some maven plugin to detect the Quality Gate Status. The failure looks like caused by the Maven.

For below error:

18:48:22,043 ERROR - Step 'master>Builds for SonarCube?VSVersion=2019>SonarCube Parallel>SonarCube?SonarOutput=E:\DailyBuild\SER_SONARQUBE\sonar-HAL-FwLoaders>Build SonarCube' is failed: Wait for Quality Gate failed.

it is because QuickBuild didn't receive any webhook result from SonarQube. So, please go to your SonarQube server and check the delivery status.

sonar-side-webhook.png
MFalkner ·

Hi@steveluo

I'm not aware of any maven plugin, this seems to be part of the sonar scanner.
Maybe I find a setting to disable this, sonar.qualitygate.wait=false did not help so far.

And yes, you are right, on SonarQube the 'Last Delivery' shows red x.
Capture.JPG

However, no my knowledge, I've configured everything to your instructions. Is there any way to debug this?

Capture1.JPG Capture2.JPG Capture3.JPG
steveluo ADMIN ·

Hi@MFalkner ,

I use below repository as my test project, you may have a look:

You can click the details icon to check what's the problem on that delivery:

Pasted_Image_2022_9_9__16_31.png

I can't find any problems in your settings picture. Just make sure the webhook secret is identical. And firstly, let's check the error reported from the delivery.

MFalkner ·

Hi@steveluo,

The last delivery shows error 401 (lacks valid authentication credentials for the requested resource).

Last delivery of QuickBuildServer
Response: 401

Duration: 256ms

Payload:

{
"serverUrl": "http://localhost:9000",

I'm not sure what I missed, could it be a firewall issue?
PS: Meanwhile I tried a run with firewall off, no change.
Also, strangely, the delivery report only shows localhost addresses, no indication that is has been delivered to the QB server.

I also verified the webhook secrete, it's identical.

steveluo ADMIN ·

Hi@MFalkner

You need create a group named "anonymous" with REST permission

qb.png
MFalkner ·

Hi@steveluo

Many thanks, this helped!

Now some more questions related to the report itself:
I've got four separate sub projects in this build. The report lists only three of them, all in one single result.
Is the number of conditions maybe limited to 18 and this the reason I see only 3 of them (3 times 6 conditions)?
Is it possible to group the result, similar to to other reports (e.g. CppCheck Report Set Name) or artifacts destination directory?
Or, would it be possible to add the project name (or key) to the report to differentiate the single results?

steveluo ADMIN ·