7

On TFS, I am not being able to run the taks "Publish Analysis Result" to publish Quality Gate on TFS web page. The other tasks "Prepare analysis on SonarQube" and "Run Code Analysis" runs successfully.

The error messages are:

[error][SQ] Could not fetch metrics

[error][SQ] Could not fetch task for ID 'FWK9NiOFibiMfA2L0BHo'

Despite the error message, when I access the url http://localhost:9000/api/ce/task?id=FWK9NiOFibiMfA2L0BHo I get a json response with the task information.

Navneet Krishna
  • 5,009
  • 5
  • 25
  • 44

1 Answers1

6

Seems it's an issue with the SonarQube VSTS Extensions:

The SonarQube extension uses basic authentication to communicate with the SonarQube API endpoint, and uses the token as username, and password as null. The npm package 'request' (at least latest version 2.83.0), does not allow null passwords and returns 'auth() received invalid user or password'.

To fix it, the password should be set to an empty string instead.

Until the VSTS plugin is fixed by SonarSource, you can workaround the issue by manually editing the extension on your VSTS build machine. The file to edit is: <build location>\_tasks\SonarQubePublish_291ed61f-1ee4-45d3-b1b0-bf822d9095ef\4.0.0\common\helpers\request.js

Add a new row after row 22:

options.auth.pass = "";

Just refer to this similar thread for details : Unable to integrate SonarQube analysis results with VSTS Build Summary

Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55
  • 1
    Thank you for this nice investigation. I have created a ticket, and will fix it: https://jira.sonarsource.com/browse/VSTS-134 – Julien H. - SonarSource Team Feb 01 '18 at 10:41
  • As a workaround, I think you can update your SonarQube endpoint definition: set the token again and save, it should be enough. – Julien H. - SonarSource Team Feb 01 '18 at 10:44
  • @JulienH.-SonarSourceTeam, the work around didn't work for me. I'm using a VSTS hosted agent and SonarCloud. I tried creating a brand new endpoint with my token and received the same error. – Tim Wilson Feb 01 '18 at 15:23
  • I was using the SonarQube extension when I should have been using the SonarCloud extension...oops. It works as expected with the SonarCloud extension. – Tim Wilson Feb 01 '18 at 16:06
  • I confirm the workaround doesn't work :( my bad. Fix is coming. – Julien H. - SonarSource Team Feb 01 '18 at 17:23
  • Thanks a lot for your replies, Andy and Julien! As I do not have access to the TFS machine, I will not be able to apply the work around suggested by Andy. For now, I am using the version SonarQube version 3 on TFS. In this version, I am able to see Quality Gate on TFS. – Igor Paladino Feb 05 '18 at 09:24