[英]how to skip the stage if my build stage fails in jenkins pipeline?
I am using three stages here , In this if my second stage Build fails it should skip the third stage copy . 我在这里使用三个阶段,如果我的第二阶段Build失败,它应该跳过第三阶段副本 。 may i know how to use conditions here in pipeline job? 我可以知道如何在管道工作中使用条件吗?
node('') {
stage ('clone'){
Build job : 'Job1'
}
stage ('Build'){
parallel(firstTask: {
stage ('Job2'){
build job: 'Job2', propagate: true
}
}, secondTask: {
stage ('Job3'){
build job: 'Job3', propagate: true
}
})
stage ('copy'){
build job: 'copy'
}
}
}
when {}
. 我经常使用的选项之一是when {}
。 Here is an example- 这是一个例子 - Jenkinsfile (Declarative Pipeline)
pipeline {
agent any
stages {
stage('Example Build') {
steps {
echo 'Hello World'
}
}
stage('Example Deploy') {
when {
branch 'production'
}
steps {
echo 'Deploying'
}
}
}
}
For more details and options, refer this documentation - https://jenkins.io/doc/book/pipeline/syntax/ 有关更多详细信息和选项,请参阅此文档 - https://jenkins.io/doc/book/pipeline/syntax/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.