Best approach for trigger build only new added branches when scan multi-branch pipeline

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

Best approach for trigger build only new added branches when scan multi-branch pipeline

BTH
Dear folks,

I have a limited resources Jenkins server and a bunch of multi-branch pipelines which are poll from GitLab repositories (scripted jenkins pipeline ).

Then I've noticed that my Jenkins usually crash by run out of memory when someone click on scan multi-branch and its triggers build multiple pipelines at the same time.

My desired is only trigger automatically build the pipeline for only new added branch.
Right now I have master, hot-fix, release, support, develop and loads of features branches.
(The feature branches are frequently added)   

Then I searched for a solution, 'Suppress automatic scm triggering'  might help me. But it will block only the specific branch that we've set in the Jenkins's configuration rather than build new whatever added branch (it can be feature, support or any custom created branches). I don't want to strict the build with a specific branch.

So I came here for find the best approach for this issue. Any suggestions are welcomed

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/ff8a4edb-604c-4bdc-bd13-28b62ed2c44en%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Best approach for trigger build only new added branches when scan multi-branch pipeline

Gianluca
I can see some ways to achieve that.
You can look at the "triggeredBy" option to use in the "when" block to avoid build the pipeline is not triggered but what you want.
For example, we do this:

when {
  anyOf {
     triggeredBy 'UpstreamCause'
     triggeredBy 'UserIdCause'
  }
}

Because we don't want that pipeline to run on scan multi-branch, push commits and other things.

If there isn't any trigger that fits your case, then you can still create a little Groovy script that returns a boolean and use inside the when anyway like that:

when {
  expression {
    FSTChangePatterns.any{pattern -> sideCars.areFilesChanged(pattern)}
  }
}

I don't know other ways to achieve what you want but they may be there are.

Cheers,
Gianluca.
Il giorno mercoledì 16 settembre 2020 alle 10:07:39 UTC+1 [hidden email] ha scritto:
Dear folks,

I have a limited resources Jenkins server and a bunch of multi-branch pipelines which are poll from GitLab repositories (scripted jenkins pipeline ).

Then I've noticed that my Jenkins usually crash by run out of memory when someone click on scan multi-branch and its triggers build multiple pipelines at the same time.

My desired is only trigger automatically build the pipeline for only new added branch.
Right now I have master, hot-fix, release, support, develop and loads of features branches.
(The feature branches are frequently added)   

Then I searched for a solution, 'Suppress automatic scm triggering'  might help me. But it will block only the specific branch that we've set in the Jenkins's configuration rather than build new whatever added branch (it can be feature, support or any custom created branches). I don't want to strict the build with a specific branch.

So I came here for find the best approach for this issue. Any suggestions are welcomed

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/3588060c-42a5-4bfe-bc89-1fe101cb84e7n%40googlegroups.com.