Skip a Jenkins job build in a pipeline

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Skip a Jenkins job build in a pipeline

Vijay Gongle
I have a Jenkins pipeline which has 10 Jobs configured to run one after the other in the post build action. 
Anytime there's a change in Job's related git code, the build is triggered and all the following jobs run though rest of the Job code were not committed. 

For e.g, in a series of 10 jobs in the pipeline, if there's a code change in 2nd job but not in 3rd job then I would like to skip the 2nd job and build the 3rd job directly. 
Likewise, any job where the code is not changed, would like to skip and jump to following job. 

Please help me if there;s a way to resolve this unwanted builds in the pipeline.  

--
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/345f6008-fdd7-4ff8-bb84-4018c99dd956%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Skip a Jenkins job build in a pipeline

Mark Waite-2
One technique is to create a single Jenkins Pipeline job that performs all 10 of those steps, then use the declarative Pipeline ability to conditionally skip a step based on conditions you decide.

However, I've never tried to manage that complex a Pipeline job, so I can't comment more than to suggest you might experiment with that technique.

On Tue, Jul 2, 2019 at 7:48 AM Vijay Gongle <[hidden email]> wrote:
I have a Jenkins pipeline which has 10 Jobs configured to run one after the other in the post build action. 
Anytime there's a change in Job's related git code, the build is triggered and all the following jobs run though rest of the Job code were not committed. 

For e.g, in a series of 10 jobs in the pipeline, if there's a code change in 2nd job but not in 3rd job then I would like to skip the 2nd job and build the 3rd job directly. 
Likewise, any job where the code is not changed, would like to skip and jump to following job. 

Please help me if there;s a way to resolve this unwanted builds in the pipeline.  

--
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/345f6008-fdd7-4ff8-bb84-4018c99dd956%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Thanks!
Mark Waite

--
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/CAO49JtHcL8LwBDhhT9v9Sg077f%2Bq9%2BSevKzuQb8vZM%3DMcYnVWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Skip a Jenkins job build in a pipeline

Nalin Garg
In reply to this post by Vijay Gongle
I had a similar need. I ended up querying git to give list of all files that were changed in PR. And then have logic around what files would be wrapped in "if, else"/ "when" block. 
 
On Tuesday, July 2, 2019 at 6:48:23 AM UTC-7, Vijay Gongle wrote:
I have a Jenkins pipeline which has 10 Jobs configured to run one after the other in the post build action. 
Anytime there's a change in Job's related git code, the build is triggered and all the following jobs run though rest of the Job code were not committed. 

For e.g, in a series of 10 jobs in the pipeline, if there's a code change in 2nd job but not in 3rd job then I would like to skip the 2nd job and build the 3rd job directly. 
Likewise, any job where the code is not changed, would like to skip and jump to following job. 

Please help me if there;s a way to resolve this unwanted builds in the pipeline.  

--
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/30c85793-81c0-4b16-9cb0-bc40d62bede1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Skip a Jenkins job build in a pipeline

Karan Kaushik
In reply to this post by Vijay Gongle
Hi
If you have a free-style job, you could convert it to pipeline job, so that you can use leverage using conditional flows in it.

On Tuesday, July 2, 2019 at 7:18:23 PM UTC+5:30, Vijay Gongle wrote:
I have a Jenkins pipeline which has 10 Jobs configured to run one after the other in the post build action. 
Anytime there's a change in Job's related git code, the build is triggered and all the following jobs run though rest of the Job code were not committed. 

For e.g, in a series of 10 jobs in the pipeline, if there's a code change in 2nd job but not in 3rd job then I would like to skip the 2nd job and build the 3rd job directly. 
Likewise, any job where the code is not changed, would like to skip and jump to following job. 

Please help me if there;s a way to resolve this unwanted builds in the pipeline.  

--
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/c12ce8fc-9383-46de-9251-00db77b07654%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Skip a Jenkins job build in a pipeline

Ivan Fernandez Calvo
In reply to this post by Nalin Garg


El martes, 2 de julio de 2019, 18:44:39 (UTC+2), Nalin Garg escribió:
I had a similar need. I ended up querying git to give list of all files that were changed in PR. And then have logic around what files would be wrapped in "if, else"/ "when" block. 
 

I preffer to use `when` at stage level it is cleaner https://jenkins.io/doc/book/pipeline/syntax/#when 

--
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/705b236b-e627-4605-bb01-f1033a399d4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.