gpt4 book ai didi

jenkins-pipeline - 在脚本化管道中发布等价物?

转载 作者:行者123 更新时间:2023-12-03 09:59:55 24 4
gpt4 key购买 nike

与声明性管道相比,脚本化管道中“post”的语法是什么?
https://jenkins.io/doc/book/pipeline/syntax/#post

最佳答案

对于脚本化管道,一切都必须以编程方式编写,大部分工作在 finally 中完成。堵塞:
Jenkinsfile (脚本管道):

node {
try {
stage('Test') {
sh 'echo "Fail!"; exit 1'
}
echo 'This will run only if successful'
} catch (e) {
echo 'This will run only if failed'

// Since we're catching the exception in order to report on it,
// we need to re-throw it, to ensure that the build is marked as failed
throw e
} finally {
def currentResult = currentBuild.result ?: 'SUCCESS'
if (currentResult == 'UNSTABLE') {
echo 'This will run only if the run was marked as unstable'
}

def previousResult = currentBuild.getPreviousBuild()?.result
if (previousResult != null && previousResult != currentResult) {
echo 'This will run only if the state of the Pipeline has changed'
echo 'For example, if the Pipeline was previously failing but is now successful'
}

echo 'This will always run'
}
}

https://jenkins.io/doc/pipeline/tour/running-multiple-steps/#finishing-up

关于jenkins-pipeline - 在脚本化管道中发布等价物?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48989238/

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