Can I use "jenkins job builder" and create pipeline job, which I could run only specific stages in? Something like this:
pipeline:
if (condition):
stage1:
//...
if (condition):
stage2:
//...
or
pipeline:
stage1:
if (condition):
//...
stage2:
if (condition):
//...
Yes, you can add conditions in your Jenkinsfile. You have to define all your stages, and inside you add condition (like your second example). You can use the when
expression to do this: https://www.jenkins.io/doc/book/pipeline/syntax/#when
You could use something like this, I hope this helps
stage ('build') {
when {
expression { condition() }
}
steps {
sh "mvn clean package "
}
}
stage ('build') {
when {
expression { condition() }
}
steps {
sh "mvn clean install"
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.