我在 K8S 上使用 Jenkins。
突然我的一个容器在 Jenkinsfile 中失败了,昨天一切正常,但突然它失败了
我没有升级任何插件,甚至没有安装任何新插件。
编辑:我已将官方 curl 图像上传到私人存储库
我的詹金斯文件有以下内容
podTemplate(
containers: [
containerTemplate(name: 'helm', alwaysPullImage: true, image: 'private-repo.com:8023/lachlanevenson/k8s-helm:v3.4.2', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'curl', alwaysPullImage: true, image: 'private-repo.com:8023/curlimages/curl', command: 'cat', ttyEnabled: true)
],
imagePullSecrets: ['registry-credentials']) {
properties([parameters(
[string(name: 'dockerImageTag', description: 'Docker image tag to deploy'),
string(name: 'branchName', defaultValue: 'dev', description: 'Branch being deployed'),
string(name: 'targetBranch', defaultValue: 'dev', description: 'Target branch against which if a PR is being raised')])])
currentBuild.description = "branch ${params.branchName}"
node(POD_LABEL) {
container('helm') {
//code here working fine
}
container('curl') {
stage('Refresh Gateway routes') {
sh script: 'curl -X POST \\\n' +
' http://my-server.com/actuator/gateway/refresh \\\n' +
' -H \'Accept: application/json\' \\\n' +
' -H \'Host: my-server.com\' \\\n' +
' -H \'cache-control: no-cache\'', label: 'Force refresh routes cache'
}
}
}
}
所以我的第二个容器只有curl命令,它工作正常,但突然给我一个错误,如下所示
sh: can't create /home/jenkins/agent/workspace/sling-sales/sd-config/deploy-to-qa@tmp/durable-4549c114/jenkins-log.txt: Permission denied
sh: can't create /home/jenkins/agent/workspace/sling-sales/sd-config/deploy-to-qa@tmp/durable-4549c114/jenkins-result.txt.tmp: Permission denied
mv: can't rename '/home/jenkins/agent/workspace/sling-sales/sd-config/deploy-to-qa@tmp/durable-4549c114/jenkins-result.txt.tmp': No such file or directory
touch: /home/jenkins/agent/workspace/sling-sales/sd-config/deploy-to-qa@tmp/durable-4549c114/jenkins-log.txt: Permission denied
touch: /home/jenkins/agent/workspace/sling-sales/sd-config/deploy-to-qa@tmp/durable-4549c114/jenkins-log.txt: Permission denied
当我检查正在运行的吊舱时,我得到了一些详细信息,如下所示
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 4m56s default-scheduler Successfully assigned default/sling-sales-sd-config-deploy-to-qa-3-rksjh-mt0js-f3tk8 to sd-jenkins-cluster-node-g7ow
Normal Pulling 4m54s kubelet, sd-jenkins-cluster-node-g7ow Pulling image "private-repo.com:8023/sling/jenkins/curl"
Normal Pulled 4m54s kubelet, sd-jenkins-cluster-node-g7ow Successfully pulled image "private-repo.com:8023/sling/jenkins/curl"
Normal Created 4m54s kubelet, sd-jenkins-cluster-node-g7ow Created container curl
Normal Started 4m54s kubelet, sd-jenkins-cluster-node-g7ow Started container curl
Normal Pulling 4m54s kubelet, sd-jenkins-cluster-node-g7ow Pulling image "private-repo.com:8023/lachlanevenson/k8s-helm:v3.4.2"
Normal Pulled 4m54s kubelet, sd-jenkins-cluster-node-g7ow Successfully pulled image "private-repo.com:8023/lachlanevenson/k8s-helm:v3.4.2"
Normal Created 4m54s kubelet, sd-jenkins-cluster-node-g7ow Created container helm
Normal Started 4m54s kubelet, sd-jenkins-cluster-node-g7ow Started container helm
Normal Pulled 4m54s kubelet, sd-jenkins-cluster-node-g7ow Container image "jenkins/inbound-agent:4.3-4" already present on machine
Normal Created 4m54s kubelet, sd-jenkins-cluster-node-g7ow Created container jnlp
Normal Started 4m54s kubelet, sd-jenkins-cluster-node-g7ow Started container jnlp
运行 jenkins pod 的日志如下
Jan 13, 2021 2:19:57 PM hudson.remoting.jnlp.Main createEngine
INFO: Setting up agent: sling-sales-sd-config-deploy-to-qa-3-rksjh-mt0js-f3tk8
Jan 13, 2021 2:19:57 PM hudson.remoting.jnlp.Main$CuiListener <init>
INFO: Jenkins agent is running in headless mode.
Jan 13, 2021 2:19:57 PM hudson.remoting.Engine startEngine
INFO: Using Remoting version: 4.3
Jan 13, 2021 2:19:57 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using /home/jenkins/agent/remoting as a remoting work directory
Jan 13, 2021 2:19:57 PM org.jenkinsci.remoting.engine.WorkDirManager setupLogging
INFO: Both error and output logs will be printed to /home/jenkins/agent/remoting
Jan 13, 2021 2:19:57 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Locating server among [http://jenkins.sling-dev.com:8080/]
Jan 13, 2021 2:19:57 PM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
INFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping]
Jan 13, 2021 2:19:57 PM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
INFO: Remoting TCP connection tunneling is enabled. Skipping the TCP Agent Listener Port availability check
Jan 13, 2021 2:19:57 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Agent discovery successful
Agent address: jenkins-master-agent
Agent port: 50000
Identity: 50:64:22:83:23:d1:5b:25:da:01:51:0e:7d:c8:8a:a9
Jan 13, 2021 2:19:57 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Handshaking
Jan 13, 2021 2:19:57 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connecting to jenkins-master-agent:50000
Jan 13, 2021 2:19:57 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Trying protocol: JNLP4-connect
Jan 13, 2021 2:19:57 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Remote identity confirmed: 50:64:22:83:23:d1:5b:25:da:01:51:0e:7d:c8:8a:a9
Jan 13, 2021 2:19:58 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connected
有人可以帮我解决这个问题吗?
谢谢阿尔佩什