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

╄→尐↘猪︶ㄣ 提交于 2019-11-30 03:57:09

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/48544346/sonarqube-v-4-tfs-task-publish-analysis-result-throw-error-could-not-fetch-me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!