首页 > 解决方案 > 具有并行阶段的 Jenkins 管道导致“进程显然从未启动”错误

问题描述

我正在尝试设置一个 Jenkins 管道(使用声明性语法),该管道在两个单独的按需 AWS EC2 实例上运行单元和功能测试。当在单个实例上运行且没有并行阶段时,管道可以完美运行。一旦我切换到并行阶段,任何 shell 脚本都会失败并显示以下神秘消息:

进程显然从未在 /home/admin/workspace/GSWebRuby_Test@tmp/durable-b0d8c4b4 开始(使用 -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true 临时运行 Jenkins 可能会使问题更清楚)

我在 Google 上进行了广泛搜索,发现了几个似乎是造成此消息的Durable Task 插件的错误报告。我正在使用最新版本的插件 v. 1.33 并且似乎没有任何问题适用于我的案例,例如异常架构或运行 Docker 容器时的故障。我还对插件进行了降级和重新升级(在 1.30 和 1.33 版本之间切换)。此外,要重新迭代,sh当我不使用parallel阶段时,命令可以正常工作。

我创建了一个简化的管道来调试问题。请注意,shell 命令也很简单,例如“env | sort”或“pwd”。

pipeline {
  agent none
  environment {
    DB_USER = credentials('db-user')
    DB_PASS = credentials('db-pass')
  }
  stages {
    stage('Setup'){
      failFast false
      parallel {
        stage('foo') {
          agent {
            label 'jenkins-slave-ondemand'
          }
          steps {
            echo 'In stage foo'
            sh 'env|sort'
          }
        }
        stage('bar') {
          agent {
            label 'jenkins-slave-ondemand'
          }
          steps {
            echo 'In stage bar'
            sh 'pwd'
          }
        }
      }
    }
  }
}

这是控制台输出:

Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] withCredentials
Masking supported pattern matches of $DB_PASS or $DB_USER
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Setup)
[Pipeline] parallel
[Pipeline] { (Branch: foo)
[Pipeline] { (Branch: bar)
[Pipeline] stage
[Pipeline] { (foo)
[Pipeline] stage
[Pipeline] { (bar)
[Pipeline] node
[Pipeline] node
Still waiting to schedule task
All nodes of label ‘jenkins-slave-ondemand’ are offline
Still waiting to schedule task
All nodes of label ‘jenkins-slave-ondemand’ are offline
Running on EC2 (Jenkins AWS EC2) - Jenkins slave (i-0982299c572100c71) in /home/admin/workspace/GSWebRuby_Test
[Pipeline] {
[Pipeline] echo
In stage foo
[Pipeline] sh
Running on EC2 (Jenkins AWS EC2) - Jenkins slave (i-092ecac8e6c257270) in /home/admin/workspace/GSWebRuby_Test
[Pipeline] {
[Pipeline] echo
In stage bar
[Pipeline] sh
process apparently never started in /home/admin/workspace/GSWebRuby_Test@tmp/durable-b0d8c4b4
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
Failed in branch foo
process apparently never started in /home/admin/workspace/GSWebRuby_Test@tmp/durable-b6cfcff9
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
Failed in branch bar
[Pipeline] // parallel
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] End of Pipeline
ERROR: script returned exit code -2
Finished: FAILURE

我在设置管道的方式上做错了吗?任何指针将不胜感激。

编辑

设置后JENKINS_JAVA_OPTIONS org.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true,我看到了这个额外的输出:

In stage bar
[Pipeline] sh
nohup: failed to run command 'sh': No such file or directory
process apparently never started in /home/admin/workspace/GSWebRuby_Test@tmp/durable-099a2e56

标签: jenkinsjenkins-pipelinejenkins-plugins

解决方案


推荐阅读