Reputation: 3
I have a git repo with a master branch, and different feature branches.
I have connected it to Jenkins, so it triggers each time there is a push or a pull request. I also have a Jenkins file with several stages: build, check1, check2 etc.
I want to disable running the stages when there is a push in a feature branch. Every push trigger, should run if it is from master.
Any idea how to achieve this?
Thanks
Upvotes: 0
Views: 239
Reputation: 1558
Another way may be using comparator
as in from here
when { branch pattern: "feature\\.+", comparator: "REGEXP"}
Upvotes: 0
Reputation: 9212
Just add this when condition on those stages like this for feature branches.
stage ('Do not Run stage for feature') {
when {
expression { return !env.GIT_BRANCH.contains('feature') }
}
steps {
sh 'echo Hello'
}
}
This above stage only get's executed when it's master branch.
Upvotes: 1