Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sonarqube v.4 TFS task "Publish Analysis Result" throw error "Could not fetch metrics"

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.

like image 780
Igor Paladino Avatar asked Jan 31 '18 14:01

Igor Paladino


1 Answers

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

like image 122
Andy Li-MSFT Avatar answered Nov 18 '22 11:11

Andy Li-MSFT