Issue
I want the following Jenkinsfile
stage
stage('building & pushing latest image') {
when {
allOf {
changeset 'my-directory/**/*'
expression {
env.BRANCH_NAME == 'master'
}
}
}
to be executed when both conditions are valid:
a) there are changes in/under my-directory
b) there is a merge to master
. ideally I would like this to be executed when
- there is a pull request targeting master
- after the merge occurs.
However for some reason the above did not run after a merge I performed.
Is something wrong with my when
condition?
Solution
Just use branch 'master';
instead of your expression block.
EDIT: I'd also suggest making sure your SCM doesn't need an additional web hook integration created. I had to do this for an older version of Bitbucket Server.
Answered By - Derek Williams