Jenkins 管道 sh 步骤返回错误“进程显然从未启动”

Bil*_*mad 2 jenkins jenkins-plugins kubernetes jenkins-pipeline

我一直在尝试让 Jenkinsfile 工作。它一直在sh步骤上失败并给出以下错误

    process apparently never started in /home/jenkins/workspace
    ...
    (running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
Run Code Online (Sandbox Code Playgroud)

我尝试过添加

withEnv(['PATH+EXTRA=/usr/sbin:/usr/bin:/sbin:/bin'])
Run Code Online (Sandbox Code Playgroud)

在 groovy 文件中的 sh 步之前

还尝试添加

/bin/sh 
Run Code Online (Sandbox Code Playgroud)

Manage Jenkins -> Configure Systemshell 部分

我还尝试用以下内容替换 Jenkinsfile 中的 sh 行:

sh "docker ps;"
sh "echo 'hello';"
sh ./build.sh;"
sh ```
#!/bin/sh
echo hello
```
Run Code Online (Sandbox Code Playgroud)

这是 Jenkinsfile 中我所坚持的部分

node {
    stage('Build') {
        echo 'this works'
        sh 'echo "this does not work"'
    }
}
Run Code Online (Sandbox Code Playgroud)

预期输出是“这不起作用”,但它只是挂起并返回上面的错误。

我缺少什么?

Bil*_*mad 5

事实证明,默认 jnlp k8s 从属节点的默认工作目录值现在设置为/home/jenkins/agent,而我正在使用旧值/home/jenkins

这是对我有用的配置

containerTemplate(name: 'jnlp', image: 'lachlanevenson/jnlp-slave:3.10-1-alpine', args: '${computer.jnlpmac} ${computer.name}', workingDir: '/home/jenkins/agent')
Run Code Online (Sandbox Code Playgroud)