Jenkinsfile withSonarQubeEnv完成:成功执行步骤后失败

问题描述 投票:0回答:1

我们有一个jenkins管道工作,在成功执行所有阶段后失败。

管道叫做sonartest,它从git获取一个jenkinsfile sonar.jenkins。

示例脚本是将我们真正的jenkins文件剥离到导致问题的部分的结果。在真正的jenkins文件中,在withSonarQubeEnv中并行执行了几次声纳扫描。扫描本身都是成功的,在示例中我用简单的dir语句替换它们。

如果我删除withSonarQubeEnv,管道不会出错。

样品

def nodelabel = "windows"
def applroot = "C:\\temp\\"

node(nodelabel) {
        stage('SonarQube training analysis') {
            withSonarQubeEnv('SonarQube') {

                dir("${applroot}") {
                      bat "dir"
                }

            }
        }
}

控制台输出

Started by user 
Obtained buildfiles/sonar.jenkins from git ssh://git:7999/gitest/jenkinsbuildtest.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on hostname in C:\workspaces\jenkins\workspace\sonartest
[Pipeline] {
[Pipeline] stage
[Pipeline] { (SonarQube training analysis)
[Pipeline] withSonarQubeEnv
Injecting SonarQube environment variables using the configuration: SonarQube
[Pipeline] {
[Pipeline] dir
Running in C:\temp
[Pipeline] {
[Pipeline] bat

C:\temp>dir
 Volume in drive C has no label.
 Volume Serial Number is 9E5D-D8F8

 Directory of C:\temp

18/02/2019  15:00    <DIR>          .
18/02/2019  15:00    <DIR>          ..

// trimmed

            8061 File(s)     80ÿ494ÿ243 bytes
              21 Dir(s)  130ÿ154ÿ577ÿ920 bytes free
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // withSonarQubeEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from hostname/XXX.XXX.XXX.31:61231
        at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1743)
        at hudson.remoting.UserResponse.retrieve(UserRequest.java:389)
        at hudson.remoting.Channel.call(Channel.java:957)
        at hudson.FilePath.act(FilePath.java:1068)
        at hudson.FilePath.act(FilePath.java:1057)
        at hudson.FilePath.list(FilePath.java:1891)
        at hudson.FilePath.list(FilePath.java:1875)
        at hudson.FilePath.list(FilePath.java:1860)
        at hudson.plugins.sonar.utils.SonarUtils.extractReportTask(SonarUtils.java:84)
        at hudson.plugins.sonar.utils.SonarUtils.addBuildInfoTo(SonarUtils.java:111)
        at hudson.plugins.sonar.SonarBuildWrapper$AddBuildInfo.tearDown(SonarBuildWrapper.java:170)
        at org.jenkinsci.plugins.workflow.steps.CoreWrapperStep$Callback.finished(CoreWrapperStep.java:152)
        at org.jenkinsci.plugins.workflow.steps.CoreWrapperStep$Execution2$Callback2.finished(CoreWrapperStep.java:122)
        at org.jenkinsci.plugins.workflow.steps.GeneralNonBlockingStepExecution$TailCall.lambda$onSuccess$0(GeneralNonBlockingStepExecution.java:140)
        at org.jenkinsci.plugins.workflow.steps.GeneralNonBlockingStepExecution.lambda$run$0(GeneralNonBlockingStepExecution.java:77)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
java.io.IOException: C:\workspaces\jenkins\workspace\sonartest does not exist.
    at hudson.FilePath.glob(FilePath.java:1931)
    at hudson.FilePath.access$3200(FilePath.java:209)
    at hudson.FilePath$ListGlob.invoke(FilePath.java:1905)
    at hudson.FilePath$ListGlob.invoke(FilePath.java:1893)
    at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3041)
    at hudson.remoting.UserRequest.perform(UserRequest.java:210)
    at hudson.remoting.UserRequest.perform(UserRequest.java:53)
    at hudson.remoting.Request$2.run(Request.java:358)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at hudson.remoting.Engine$1$1.run(Engine.java:94)
    at java.lang.Thread.run(Unknown Source)
Finished: FAILURE

jenkins-pipeline sonarqube-scan
1个回答
0
投票

我找到了解决这个问题的方法。当我把withSonarQubeEnv放在dir("${applroot}") {}。在简化的示例中,不再需要内部目录,在我的真实世界脚本中,在不同目录中存在多个不同的并行执行的声纳。

解决

def nodelabel = "windows"
def applroot = "C:\\temp\\"

node(nodelabel) {
    stage('SonarQube training analysis') {
        dir("${applroot}") {
            withSonarQubeEnv('SonarQube') {
                dir("${applroot}") {
                     bat "dir"
                }
            }
        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.