Trigger separate jobs with two distinct Jenkinsfiles

52 views
Skip to first unread message

Ian Vernon

unread,
Dec 13, 2017, 4:53:26 PM12/13/17
to Jenkins Users
Hello! I am new to Jenkins, and would appreciate help with the following scenario.

I have been tasked with migrating an existing testing framework to a new one for my team's CI infrastructure. This resulted in the need for a rewrite of our current, existing tests. As a result, we now have a Jenkinsfile for the old set of steps to run for the old tests, and a new one for the new set of tests. I would like to have the following occur:

When a PR is opened, trigger two separate jobs on Jenkins. each of these jobs is part of a GitHub Organization that in turn opens up a job for each PR. These two jobs gate whether the build succeeds. I do not want to combine these two jobs to be part of the same Jenkinsfile, as that would require a significant refactoring of the code that has been done already, as the tests step on each other's toes considerably.

Basically, how do I configure Jenkins so that these two jobs are triggered when a PR is opened / pushed within the context of a GitHub Organization? I can only currently figure out how to have one job run per PR. 

I'd be happy to provide more information if needed. Thanks!

Victor Martinez

unread,
Dec 13, 2017, 5:10:45 PM12/13/17
to Jenkins Users
if the old tests will be deprecated and removed sooner than later, cannot you just use the https://jenkins.io/doc/pipeline/steps/pipeline-build-step/#build-build-a-job step?

Then, the Jenkinsfile will trigger two parallel branches, the first one about the new tests using whatever is part of the jenkinsfile for running the new tests, and the second branch will be to trigger another traditional jenkins job which will run the old test (using the above build step)

I don't know if it makes sense in your case, but I guess it might simplify the pipeline tweaking.

Ian Vernon

unread,
Dec 13, 2017, 5:18:19 PM12/13/17
to Jenkins Users
Thanks for the quick reply - that's an intriguing proposition! 

Do you know if all builds from each PR go to the same job that is created in the build-a-job step?

Stephen Connolly

unread,
Dec 13, 2017, 5:29:19 PM12/13/17
to jenkins...@googlegroups.com
Use a shared library to define the steps with a common name.

Each branch will just have a Jenkinsfile of

ourStandardBuild();

Then you define two org folders. One for the new build and the other for the old build. 

Add the respective shared library to each org folder.

See Watch Me Code Episodes 4&5 for how to do this.


--
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/efd618d2-3c61-4a4b-a2de-1f1258a3853f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Sent from my phone

Victor Martinez

unread,
Dec 13, 2017, 5:36:53 PM12/13/17
to Jenkins Users
Do you know if all builds from each PR go to the same job that is created in the build-a-job step?

Yes, indeed. I don't know in your specific use case, but using concurrent builds you can solve concurrent PR executions if you got enough agents too.

Ian Vernon

unread,
Dec 24, 2017, 12:29:00 AM12/24/17
to Jenkins Users
Setting up two organization folders was the trick. Thanks!
Reply all
Reply to author
Forward
0 new messages