So we can have only one Jenkinsfile per job. And we share the same job for both merge and PR webhooks from github. How can we easily detect if the webhook for a commit pushed in a PR or for PR merge?
This (declarative pipeline) snippet might help:
stage('do something for PRs opened against develop branch') {
when {
changeRequest target: 'develop'
}
steps {
sh 'pr-worker.sh'
}
}
stage('do something on merge or direct commits to the develop branch') {
when {
branch 'develop'
}
steps {
sh 'develop-worker.sh'
}
}
See when in the documentation.