Context: We have a Jenkins 2.361.3 server and a local Bitbucket server with webhooks (on Push) that trigger multibranch pipeline jobs (declarative jenkinsfile mode) on Jenkins for every repo push. This works fine when we have a single multibranch pipeline job on Jenkins: the build is triggered for the correct branch.
New scenario: We want a second 'nightly' multibranch pipeline job on the same Jenkins server for the same Bitbucket repo, which we want to trigger on a fixed time every day for every branch that exists at that time. It should not trigger for repo pushes.
Actions taken: We created a second multibranch pipeline job, similar to the first one but now with a cron trigger in the jenkinsfile and this setting disabled: "Build when a change is pushed to BitBucket":
This setting is still enabled for the initial job.
Expectations:
- On a repo push, only the initial job is triggered. The nightly job does nothing.
- When the cron time hits, the night job is triggered.
Actual:
- On a repo push, both jobs are triggered. (also after Jenkins restart)
- Additionally, the cron trigger works as expected.
Question: How to configure this system so that a repo push only triggers the initial job and not the nightly job?
It looks like the combination of BitBucket plugin (v223) and Multibranch Pipeline plugin (v716) does not adhere to the "Build when a change is pushed to BitBucket" setting.
Experiments performed:
- Disabling the "Build when a change is pushed to BitBucket" setting for both jobs (and restarting Jenkins) --> both jobs are still triggered by a repo push
- Remove the webhook from BitBucket and configure 'polling SCM' for both jobs --> this works but polling feels suboptimal and adds performance hits to the server.
CodePudding user response:
We solved it using the “Suppress automatic SCM triggering” property in the ‘Branch Sources’ section of the Jenkins configure page for the job, as explained