gpt4 book ai didi

jenkins - 如何在多个代理上对Jenkins管道使用发布步骤?

转载 作者:行者123 更新时间:2023-12-03 12:40:54 26 4
gpt4 key购买 nike

当使用每个阶段在不同代理上运行的Jenkins管道时,在开头使用agent nonegood practice

pipeline {
agent none
stages {
stage('Checkout') {
agent { label 'master' }
steps { script { currentBuild.result = 'SUCCESS' } }
}
stage('Build') {
agent { label 'someagent' }
steps { bat "exit 1" }
}
}
post {
always {
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "test@test.com", sendToIndividuals: true])
}
}
}


但是,这样做会导致在应发送电子邮件时导致 Required context class hudson.FilePath is missing错误消息:

[Pipeline] { (Declarative: Post Actions)
[Pipeline] step
Required context class hudson.FilePath is missing
Perhaps you forgot to surround the code with a step that provides this, such as: node
[Pipeline] error
[Pipeline] }


当我从 agent none更改为 agent any时,它可以正常工作。

如何在不使用 post的情况下使 agent any步骤起作用?

最佳答案

将执行邮件发送的step包装在node步骤中:

post {
always {
node('awesome_node_label') {
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "test@test.com", sendToIndividuals: true])
}
}
}

关于jenkins - 如何在多个代理上对Jenkins管道使用发布步骤?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44531003/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com