Publish Quality Gate Result failure

  • Versions used
    Community EditionVersion 8.2 (build 32929), SonarScanner for Azure DevOps 4.9.0
  • CI system used
    TFS 2018
  • Steps to reproduce
    Follow instructions on this page (https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-azure-devops/) to useSonarScanner for Azure DevOps plugin to setup automated SonarQube scan process for a .Net app in TFS 2018
  • Potential Workaround
    N/A
  • Error observed
    sonarqube scan pipeline failing during “Publish Quality Gate Result” step. Task error log listed below
2020-08-25T09:27:44.4682924Z ##[debug][SQ] Waiting for task 'AXQk8KvWEfrwmhYXhMDA' to complete.
2020-08-25T09:27:44.4693634Z ##[debug][SQ] API GET: '/api/ce/task' with query "{"id":"AXQk8KvWEfrwmhYXhMDA"}"
2020-08-25T09:27:44.5595504Z ##[debug]Response: 200 Body: "{"task":{"id":"AXQk8KvWEfrwmhYXhMDA","type":"REPORT","componentId":"AXP86owjpBNc-hSdS8YH","componentKey":"XXX_YYY_1234","componentName":"XXX","componentQualifier":"TRK","status":"CANCELED","submittedAt":"2020-08-25T05:26:28-0400","submitterLogin":"yyyy","startedAt":"2020-08-25T05:26:28-0400","executedAt":"2020-08-25T05:27:43-0400","executionTimeMs":74772,"logs":false,"hasScannerContext":true,"organization":"default-organization","warningCount":2,"warnings":[]}}"
2020-08-25T09:27:44.5596700Z ##[debug][SQ] Task status:CANCELED
2020-08-25T09:27:45.5694867Z ##[debug][SQ] Waiting for task 'AXQk8KvWEfrwmhYXhMDA' to complete.
2020-08-25T09:27:45.5695341Z ##[debug][SQ] API GET: '/api/ce/task' with query "{"id":"AXQk8KvWEfrwmhYXhMDA"}"
2020-08-25T09:27:45.5809003Z ##[debug]Response: 200 Body: "{"task":{"id":"AXQk8KvWEfrwmhYXhMDA","type":"REPORT","componentId":"AXP86owjpBNc-hSdS8YH",""componentKey":"XXX_YYY_1234","componentName":"XXX","componentQualifier":"TRK","status":"CANCELED","submittedAt":"2020-08-25T05:26:28-0400","submitterLogin":"yyyy","startedAt":"2020-08-25T05:26:28-0400","executedAt":"2020-08-25T05:27:43-0400","executionTimeMs":74772,"logs":false,"hasScannerContext":true,"organization":"default-organization","warningCount":2,"warnings":[]}}"
2020-08-25T09:27:45.5809619Z ##[debug][SQ] Task status:CANCELED'''

Hello Kenneth,

From the log snippets you shared it seems that the CE task ‘AXQk8KvWEfrwmhYXhMDA’ instead of being processed by SonarQube has been canceled. You can check if that was indeed the case from SQ UI in Admin->Projects->Background Tasks and filtering by the task id (are there maybe other jobs that are canceled too?).
If the task got cancelled there is no Quality Gate computed for a given scan and thus Publishing QG status makes no sense.

Greetings,
Kris

We confirmed in the UI that the Background tasks was cancelled for this job and other related jobs. The question is why. We were able to verify through the UI and pipeline that a results file was computed and uploaded to the server. Is this the Quality Gate you are referring to? Here is the output from pipeline’s Run Code Analysis step:``` 2020-09-03T11:43:25.4503026Z 07:43:25.430 INFO: Analysis report generated in 2734ms, dir size=30 MB
2020-09-03T11:43:33.3851518Z 07:43:33.367 INFO: Analysis report compressed in 7937ms, zip size=11 MB
2020-09-03T11:43:33.3853128Z 07:43:33.367 INFO: Analysis report generated in D:\Builds\VXYZ1\1.sonarqube\out.sonar\scanner-report
2020-09-03T11:43:33.3853630Z 07:43:33.367 DEBUG: Upload report
2020-09-03T11:43:34.0047115Z 07:43:33.992 DEBUG: POST 200 http://xxxxy:2345/api/ce/submit?projectKey=APP_MAIN_CI-234i&projectName=APP | time=609ms
2020-09-03T11:43:34.0115656Z 07:43:34.008 INFO: Analysis report uploaded in 641ms’‘’

Thanks for checking.

We confirmed in the UI that the Background tasks was cancelled for this job and other related jobs. The question is why.

Exactly that is the question we need to find answer to.

We were able to verify through the UI and pipeline that a results file was computed and uploaded to the server

Think about it as client/server architecture - client, being your scanner, generates a report and uploads it to the server. Then the server should queue the request and processes the uploaded report via the Compute Engine. Please check SonarQpube’s ce.log on some clues on why this task was cancelled. You can grep its id in the ce.log and hopefully there will be some clue.

Greetings,
Kris

This is the error we identified in the ce log - any thoughts?

java.lang.IllegalStateException: Task does not exist anymore: CeTask{organizationUuid=AXP8jtnZpBNc-hSdS57u, type=REPORT, uuid=AXRQsXwCEfrwmhYXhMDF, component=Component{uuid='AXP86owjpBNc-hSdS8YH', key='XXX_YYY_CI-123i', name='XXX'}, mainComponent=Component{uuid='AXP86owjpBNc-hSdS8YH', key='XXX_YYY_CI-123i', name='AIMS'}, submitter=User{uuid='AXP8lqVkpBNc-hSdS8YD', login='abcdefg'}}
                at org.sonar.ce.queue.InternalCeQueueImpl.lambda$remove$0(InternalCeQueueImpl.java:113)'''