how to build on branch creation but not build on other scm event/commit?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

how to build on branch creation but not build on other scm event/commit?

Tim Black
1. I have a multibranch pipeline job that takes 30min to run, has a lot of branches, and my company is still at the earlier stages of devops transformation, so with our current infrastructure we do not want to trigger a build every commit.

2. Our job pipeline uses parameters heavily, so I would also like to automatically build each branch on branch creation/detection. 

How do I achieve the above 2 requirements?

Using git scm/plugin/branchsource, if I set (or clear) "Suppress Automatic SCM triggering", I get only one of the two requirements fulfilled: setting it suppresses ALL automatic triggering, not providing 2. Clearing it satisfies 2, automatically triggering a build on branch discovery, but also builds every commit which we don't want.

In my research I have found the basic branch build strategies plugin, and while it provides some great sophisticated control over what branches build when, in terms of ensuring the job is built on branch creation, it seems to only provide added suppression.

Any suggestions would be welcome. Thanks.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/bc4a70ab-41f2-4189-a801-aa04b8df0f36n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: how to build on branch creation but not build on other scm event/commit?

jeremy mordkoff
You could leave the Automatic triggering suppressed and write a tool to scan your GIT repo looking for new branches and trigger the build via an API call when a new branch is found. Sounds like you might need such a tool anyway so that developers could schedule builds. 

On Thursday, September 17, 2020 at 12:59:27 AM UTC-4 [hidden email] wrote:
1. I have a multibranch pipeline job that takes 30min to run, has a lot of branches, and my company is still at the earlier stages of devops transformation, so with our current infrastructure we do not want to trigger a build every commit.

2. Our job pipeline uses parameters heavily, so I would also like to automatically build each branch on branch creation/detection. 

How do I achieve the above 2 requirements?

Using git scm/plugin/branchsource, if I set (or clear) "Suppress Automatic SCM triggering", I get only one of the two requirements fulfilled: setting it suppresses ALL automatic triggering, not providing 2. Clearing it satisfies 2, automatically triggering a build on branch discovery, but also builds every commit which we don't want.

In my research I have found the basic branch build strategies plugin, and while it provides some great sophisticated control over what branches build when, in terms of ensuring the job is built on branch creation, it seems to only provide added suppression.

Any suggestions would be welcome. Thanks.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ac468efa-99d3-458e-9114-3800ac5484d5n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: how to build on branch creation but not build on other scm event/commit?

Tim Black
Thanks Jeremy. Our developers already have control of their projects' branches' Jenkinsfiles so they can define whatever triggers/schedule they want. If I were going to hack this, I'd probably prefer to do the opposite of what you're recommending. Since git scanning is a wheel already invented many times, I'd rather NOT "Suppress Automatic SCM Triggering", but modify our pipelines (Declarative Jenkinsfile + loaded groovy file(s)) to check the "build cause" and act accordingly. Ultimately, we're likely to need this kind of sophistication anyway, since some build causes ( e.g. Branch Discovery, PR, commit, etc) may need special behavior. Ultimately ultimately, we'll have more build capacity and will be able to support per-commit builds, so perhaps some of this is temporary.

We're using Bitbucket On Prem, FWIW, and soon I will be implementing various Jenkins-Bitbucket integrations. Currently we're still just using Jenkins git plugin as BranchSource for our multibranch pipeline jobs. Perhaps once I switch us over to using the Bitbucket Server Integration plugin, a more elegant solution to this fine control over Automatic SCM Triggering will become clear.

Cheers.

On Thursday, September 17, 2020 at 9:12:17 AM UTC-7 [hidden email] wrote:
You could leave the Automatic triggering suppressed and write a tool to scan your GIT repo looking for new branches and trigger the build via an API call when a new branch is found. Sounds like you might need such a tool anyway so that developers could schedule builds. 

On Thursday, September 17, 2020 at 12:59:27 AM UTC-4 [hidden email] wrote:
1. I have a multibranch pipeline job that takes 30min to run, has a lot of branches, and my company is still at the earlier stages of devops transformation, so with our current infrastructure we do not want to trigger a build every commit.

2. Our job pipeline uses parameters heavily, so I would also like to automatically build each branch on branch creation/detection. 

How do I achieve the above 2 requirements?

Using git scm/plugin/branchsource, if I set (or clear) "Suppress Automatic SCM triggering", I get only one of the two requirements fulfilled: setting it suppresses ALL automatic triggering, not providing 2. Clearing it satisfies 2, automatically triggering a build on branch discovery, but also builds every commit which we don't want.

In my research I have found the basic branch build strategies plugin, and while it provides some great sophisticated control over what branches build when, in terms of ensuring the job is built on branch creation, it seems to only provide added suppression.

Any suggestions would be welcome. Thanks.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/bf3c640f-2cbf-4f20-8539-81ea8d1b530en%40googlegroups.com.