Jenkinsfile withSonarQubeEnv Закончено: СБОЙ после успешного выполнения шагов - PullRequest
0 голосов
/ 18 февраля 2019

У нас есть конвейерное задание jenkins, которое завершается неудачно после успешного выполнения всех этапов.

Конвейер называется sonartest, он получает файл jenkinsfile sonar.jenkins из git.

Пример сценарияявляется результатом разборки нашего реального файла jenkinsfile до той части, которая вызывает проблему.В реальном jenkinsfile есть параллельное выполнение нескольких сканирований сонара внутри withSonarQubeEnv.Сами сканы все успешны, в примере я заменил их простым оператором dir.

Конвейер не выдает ошибку, если я удалю withSonarQubeEnv.

sample

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

1 Ответ

0 голосов
/ 19 февраля 2019

Я нашел обходной путь для этой проблемы.Когда я положил withSonarQubeEnv в dir("${applroot}") {}.В упрощенном примере внутренний каталог больше не требуется, в моем сценарии реального мира есть несколько разных параллельно выполняемых сонарсканов в разных каталогах.

Работа вокруг

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

node(nodelabel) {
    stage('SonarQube training analysis') {
        dir("${applroot}") {
            withSonarQubeEnv('SonarQube') {
                dir("${applroot}") {
                     bat "dir"
                }
            }
        }
    }
}
...