Scan Multibranch Pipeline Trigger
The ‘Scan Multibranch Pipeline’ trigger will scan the repository for new branches and changes in existing branches. By default it will trigger a new build for all branches which have been updated. However in the multibranch job configuration you can disable this automatic trigger for specific - or all - branches. However, please note that you have to set up the web hook for your repository so that Jenkins will be notified of any changes. As the hook setup will depend both on the Jenkins plugin used to checkout the Jenkinsfile as well as on the Git server, you will have to look this up accordingly.
Poll SCM
The pollSCM
trigger is branch-specific. Within a Jenkinsfile you may configure different options for different branches. This option will never be able to trigger the very first build for a branch as it would need at least one build so the properties
step gets executed and the pollSCM
option set. That is: Any change here will only get effective AFTER the next build.
You can use pollSCM
trigger in two ways:
- Real polling. That is: Tell Jenkins to check the repository for changes in certain time intervals.
- Waiting for notification by some repository hook. For this you'd need to
- Keep the string passed to
pollSCM
empty:
triggers {
pollSCM('')
}
- Set up a hook on your git server to notify Jenkins (See How to configure Git post commit hook)
Recommendation
Therefore I’d recommend to stick to the trigger based on the Multibranch branch scan - if possible. However in some special cases (e.g. if the first build on a new branch should never be built automatically) it still might be useful to use the poll SCM feature. In that case you might want to disable the automatic trigger as required.
Last but not least the poll SCM feature may use a different plugin than the Scan Multibranch Pipeline, e.g. for Bitbucket.
AFAIK for Bitbucket the multibranch trigger is little bit more flexible, allows to trigger a build on more events compared the the plain Bitbucket trigger.