Skip a Jenkins job build in a pipeline

18 views
Skip to first unread message

Vijay Gongle

unread,
Jul 2, 2019, 9:48:23 AM7/2/19
to Jenkins Users
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.  

Mark Waite

unread,
Jul 2, 2019, 11:41:23 AM7/2/19
to Jenkins Users
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.

--
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 jenkinsci-use...@googlegroups.com.
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

Nalin Garg

unread,
Jul 2, 2019, 12:44:39 PM7/2/19
to Jenkins Users
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. 

Karan Kaushik

unread,
Jul 6, 2019, 4:59:31 PM7/6/19
to Jenkins Users
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.

Ivan Fernandez Calvo

unread,
Jul 13, 2019, 7:13:56 AM7/13/19
to Jenkins Users


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 
Reply all
Reply to author
Forward
0 new messages