【问题标题】:Jenkinsfile withSonarQubeEnv Finished: FAILURE after successfull execution of stepsJenkinsfile withSonarQubeEnv Finished:成功执行步骤后失败
【发布时间】:2019-07-11 23:40:29
【问题描述】:

我们有一个詹金斯管道作业在成功执行所有阶段后失败。

管道名为 sonartest,它从 git 获取 jenkinsfile sonar.jenkins。

示例脚本是将我们真正的 jenkinsfile 剥离到导致问题的部分的结果。在真正的 jenkinsfile 中,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】:

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

    解决方法

    def nodelabel = "windows"
    def applroot = "C:\\temp\\"
    
    node(nodelabel) {
        stage('SonarQube training analysis') {
            dir("${applroot}") {
                withSonarQubeEnv('SonarQube') {
                    dir("${applroot}") {
                         bat "dir"
                    }
                }
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-15
      • 2018-06-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多