Jenkins Pipeline sh 步骤挂起

Jenkins Pipeline sh 步骤挂起

我目前在 Ubuntu 18.04 上运行 Jenkins 时遇到问题。 sh 管道步骤挂起并最终超时并显示以下消息:

[Pipeline] sh
process apparently never started in /var/lib/jenkins/workspace/members-only-demo@tmp/durable-494a3b0d
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
Cannot contact : java.io.FileNotFoundException: File '/var/lib/jenkins/workspace/members-only-demo@tmp/durable-494a3b0d/output.txt' does not exist

以下是线程转储:

Thread #6
    at DSL.sh(completed process (code -2) in /var/lib/jenkins/workspace/members-only-demo@tmp/durable-494a3b0d; recurrence period: 15000ms; check task scheduled; cancelled? false done? false)
    at WorkflowScript.run(WorkflowScript:9)
    at DSL.stage(Native Method)
    at WorkflowScript.run(WorkflowScript:8)
    at DSL.node(running on )
    at WorkflowScript.run(WorkflowScript:3)

管道脚本如下:

#!/usr/bin/env groovy
node {
        stage('Checkout') {
            checkout([$class: 'GitSCM', branches: [[name: '*/da-demo']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'TeamHub2', url: '[email protected]:digitalarchitects/projects/slender-man/repositories/git/members-only-app']]])
        }
        stage('Create Build Dir') {
            sh label: '', returnStdout: true, script: 'rm --recursive --force ${env.WORKSPACE}/build/'
            sh 'mkdir --parents ${env.WORKSPACE}/build/coverage ${env.WORKSPACE}/build/logs ${env.WORKSPACE}/build/pdepend'
        }
   ...
}

我不太清楚如何解决此问题。有人能帮忙吗?

答案1

插件更新后,Jenkins k8s 节点出现同样的问题,结果发现默认 jnlp k8s 节点的默认 workingDir 值现在设置为/home/jenkins/agent,而对于 pod 中的第二个容器,我将其设置为/home/jenkins

将 workingDir 切换到/home/jenkins/agentpod 中的第二个容器即可解决问题。

答案2

我最终使用 apt-get --purge remove jenkins 然后使用 apt-get install jenkins 重新安装了 jenkins。遗憾的是,一切都必须重新配置,但问题已经解决了。

答案3

我遇到了同样的问题。这是由于 kubernetes pod 安全策略造成的。放宽 pod 策略后就没问题了。

相关内容