如何在Sonarqube Jenkins插件中指定正确的report-task.txt文件?

发布于 2025-01-24 01:59:04 字数 943 浏览 4 评论 0原文

我正在对詹金斯的node.js项目进行Sonarqube分析。 Sonar Analysis创建了Report-task.txt文件。不幸的是,node_modules文件夹中的某些模块还包含其report-task.txt文件,该文件会导致jenkins发出警告:

WARN: Found multiple 'report-task.txt' in the workspace. Taking the first one.
/jenkins/workspace/.scannerwork/report-task.txt
/jenkins/workspace/node_modules/some_module/.scannerwork/report-task.txt
/jenkins/workspace/node_modules/some_other_module/.scannerwork/report-task.txt

一切都很好,直到我的项目的声纳分析失败:然后jenkins从模块中获取不同的report-task.txt文件。在node_modules中,由于声纳分析的结果:

WARN: Found multiple 'report-task.txt' in the workspace. Taking the first one.
/jenkins/workspace/node_modules/some_module/.scannerwork/report-task.txt          <- wrong file
/jenkins/workspace/node_modules/some_other_module/.scannerwork/report-task.txt

有没有办法指定/jenkins/workspace/.scannerwork/report-task.task.txt是唯一的正确结果文件,Jenkins应该忽略所有其他的其他所有其他结果。 ?最好使用詹金斯管道

I am running a SonarQube analysis of my Node.js project in Jenkins. Sonar analysis creates report-task.txt file with the result. Unfortunately some modules in the node_modules folder also contain their report-task.txt files which results in a warning in Jenkins:

WARN: Found multiple 'report-task.txt' in the workspace. Taking the first one.
/jenkins/workspace/.scannerwork/report-task.txt
/jenkins/workspace/node_modules/some_module/.scannerwork/report-task.txt
/jenkins/workspace/node_modules/some_other_module/.scannerwork/report-task.txt

Everything is fine until the Sonar analysis for my project fails: then Jenkins takes a different report-task.txt file from a module in node_modules as a result of a Sonar analysis:

WARN: Found multiple 'report-task.txt' in the workspace. Taking the first one.
/jenkins/workspace/node_modules/some_module/.scannerwork/report-task.txt          <- wrong file
/jenkins/workspace/node_modules/some_other_module/.scannerwork/report-task.txt

Is there a way to specify that /jenkins/workspace/.scannerwork/report-task.txt is the only correct result file and Jenkins should ignore all the other? Preferably using Jenkins Pipelines

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时间海 2025-01-31 01:59:04

这是我的管道中的片段:

sh 'cat .scannerwork/report-task.txt'
// copy to a properties file so we can ingest as variables
sh 'cp .scannerwork/report-task.txt .scannerwork/report-task.properties'
def props = readProperties file: '.scannerwork/report-task.properties'
def ceTaskUrl= props['ceTaskUrl']
def sonarServerUrl=props['serverUrl']
// wait for analysis to complete
waitUntil {
    def response = httpRequest consoleLogResponseBody: true, contentType: 'APPLICATION_JSON', ignoreSslErrors: true, url: "${ceTaskUrl}", wrapAsMultipart: false
    println "Sent a request, got a $response response"
    def body = readJSON text: response.content
    body.each { key, value -> }
    ceTask = body.task.status
    echo "Status is "+ceTask
    if ("FAILED".equals(ceTask)){
    echo "failed = "+ceTask
    throw new Exception(failed+" Sonar process failed!")
    }
    return "SUCCESS".equals(ceTask)
    sleep 30
} 

This is a snippet from my pipeline:

sh 'cat .scannerwork/report-task.txt'
// copy to a properties file so we can ingest as variables
sh 'cp .scannerwork/report-task.txt .scannerwork/report-task.properties'
def props = readProperties file: '.scannerwork/report-task.properties'
def ceTaskUrl= props['ceTaskUrl']
def sonarServerUrl=props['serverUrl']
// wait for analysis to complete
waitUntil {
    def response = httpRequest consoleLogResponseBody: true, contentType: 'APPLICATION_JSON', ignoreSslErrors: true, url: "${ceTaskUrl}", wrapAsMultipart: false
    println "Sent a request, got a $response response"
    def body = readJSON text: response.content
    body.each { key, value -> }
    ceTask = body.task.status
    echo "Status is "+ceTask
    if ("FAILED".equals(ceTask)){
    echo "failed = "+ceTask
    throw new Exception(failed+" Sonar process failed!")
    }
    return "SUCCESS".equals(ceTask)
    sleep 30
} 

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文