0
votes

We recently upgraded to SonarQube Community Edition Version 7.1 (build 11001). We are also using the TFS SonarQube extension Version 4.3.1. The "Publish Quality Gate Result" build step fails with the message:

[SQ] API GET '/api/ce/task' failed, status code was: 404
[SQ] Could not fetch task for ID 'AWRg8urbC5nyQrURbDKL'

This only happens on the linux build agent. It doesn't happen on the Windows build agent. What's also interesting is that the output from the "Run Code Analysis" step seems to indicate a different task ID:

=========== Run Code Analysis Output ===========
More about the report processing at http://sonarqube:9000/api/ce/task?id=AWSFWzxYmaH45QFNcZ_C

=========== Publish Quality Gate Result Output ===========
[SQ] Could not fetch task for ID 'AWRg8urbC5nyQrURbDKL'

The URL from the Code Analysis step is valid and returns a json response containing all of the data about the task. If I replace the ID in the URL with the ID from the Publish step, I get an error json response with the message "No activity found for task".

How can this be fixed so the build step doesn't fail?

UPDATE - FIXED

After setting system.debug=true on the build, I noticed that there were two report-task.txt files that were being processed by the Publish Quality Gate Result Task: /agent/_work/2/.sonarqube/out/.sonar/report-task.txt and /agent/_work/2/s/.scannerwork/report-task.txt. The task reads the contents of those files to get the URL and Task ID for the SQ analysis. The second was left over from an older build and contained an invalid task ID. Removing that file fixed the issue.

1
Did you set proxy for SonarQube or TFS server? Have you tried to deploy a new Linux build agent and try it again? Whatever please refer to this similar thread(Olivier's reply) and this blog: [VSTS - BITNAMI SONARQUBE INTEGRATION WITH HTTPS ( SSL ) SUPPORT](bimar-arkas.blogspot.com/2018/04/… )for troubleshooting. - Andy Li-MSFT
Seems you have resolved the issue, you could post your solution as an answer and accept it, This can be beneficial to other community members reading this thread. - Andy Li-MSFT

1 Answers

2
votes

This error can occur if the build directory contains a report-task.txt file left over from a prior build. Make sure there are no report-task.txt files in the build directory by setting the Clean option to true in the build configuration.