无法将SonarQube分析结果与VSTS Build Summary集成 [英] Unable to integrate SonarQube analysis results with VSTS Build Summary

查看:56
本文介绍了无法将SonarQube分析结果与VSTS Build Summary集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在VSTS中使用准备,运行和发布"分析任务来运行SonarQube分析并发布结果以构建摘要.前两个步骤执行成功,但是发布分析"任务失败,因为它无法获取分析ID的任务.我收到以下错误消息:

I am using Prepare, Run and Publish analysis tasks in VSTS to run the SonarQube analysis and publish the results to build summary. First two steps execute successfully but the 'Publish Analysis' task fails because it is not able to fetch the task for analysis ID. I get the following error message:

无法获取ID为'AWE9-wu8-fbfJflhFQ3-'的任务

Could not fetch task for ID 'AWE9-wu8-fbfJflhFQ3-'

VSTS发布分析任务日志:

VSTS Publish Analysis Task Log:

2018-01-28T18:15:28.1037139Z ##[debug][SQ] Waiting for task 'AWE9-wu8-fbfJflhFQ3-' to complete.
2018-01-28T18:15:28.1037139Z ##[debug][SQ] API GET: '/api/ce/task' with query "{"id":"AWE9-wu8-fbfJflhFQ3-"}"
2018-01-28T18:15:28.1047138Z ##[debug][SQ] Publish task error: [SQ] Could not fetch task for ID 'AWE9-wu8-fbfJflhFQ3-'
2018-01-28T18:15:28.1047138Z ##[debug]task result: Failed
2018-01-28T18:15:28.1047138Z ##[error][SQ] Could not fetch task for ID 'AWE9-wu8-fbfJflhFQ3-'
2018-01-28T18:15:28.1047138Z ##[debug]Processed: ##vso[task.issue type=error;][SQ] Could not fetch task for ID 'AWE9-wu8-fbfJflhFQ3-'
2018-01-28T18:15:28.1047138Z ##[debug]Processed: ##vso[task.complete result=Failed;][SQ] Could not fetch task for ID 'AWE9-wu8-fbfJflhFQ3-'
2018-01-28T18:15:28.3907147Z ##[section]Finishing: Publish Analysis Result

推荐答案

我看到了与Vignesh完全相同的问题.运行SonarQube 6.7.1和最新版本的VSTS SonarQube扩展.

I was seeing the exact same problem as Vignesh. Running SonarQube 6.7.1 and latest version of VSTS SonarQube extension.

我发现了问题所在;它在SonarQube VSTS扩展中(准备,分析和发布).

I found out what the problem was; it's in the SonarQube VSTS Extensions (Prepare, Analyse & Publish).

SonarQube扩展使用基本身份验证与SonarQube API端点进行通信,并将令牌用作用户名,密码用作null. npm软件包"request"(至少最新版本为2.83.0),不允许使用空密码,并返回"auth()接收到无效的用户或密码".

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.

在SonarSource修复VSTS插件之前,您可以通过在VSTS构建计算机上手动编辑扩展名来解决此问题.要编辑的文件是:<build location>\_tasks\SonarQubePublish_291ed61f-1ee4-45d3-b1b0-bf822d9095ef\4.0.0\common\helpers\request.js

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

在第22行之后添加新行:

Add a new row after row 22:

options.auth.pass = "";

最终结果应类似于:

var options = {
    auth: endpoint.auth
};
if (query) {
    options.qs = query;
    options.useQuerystring = true;
}
options.auth.pass = "";
request.get(__assign({ method: 'GET', baseUrl: endpoint.url, uri: path, json: true }, options), function (error, response, body) {

我不做任何保证,但这对我有用.

I give no guarantees, but this worked for me.

这篇关于无法将SonarQube分析结果与VSTS Build Summary集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆