Can I use the same Multibranch Pipeline to periodically pollSCM for certain branches but also trigger for each SCM change for others?

Viewed 116

I have a Jenkins Multibranch pipeline job which at first, was automatically triggering a build for each discovered branch, upon a SCM change (default Multibranch pipeline behaviour).

I then wished for certain branches (filtered by name, those starting with "feature") to poll the SCM for changes every hour to avoid having too many builds for them. So I added the "Suppress Automatic SCM Triggering" property in the Multibranch configuration, for those branch names. All the other branch names (those starting with "bugfix") were still triggered whenever a SCM change was detected.

I was counting on the pollSCM property in the Jenkins file to be a fallback for all "feature" branches:

triggers {
    pollSCM 'H/60 * * * *'
}

but this is not read anymore because the first build of the detected "feature" branches is not run anymore. If I manually "Build now" for a "feature" branch, then the property is read and any subsequent commits are correctly polled every hour. But the problem is that I don't have this "first build" anymore so the property is unknown when the branch is detected.

Is there a solution to this? Or do I have to create two separate Multibranch pipelines?

0 Answers
Related