Trigger separate jobs with two distinct Jenkinsfiles

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

Trigger separate jobs with two distinct Jenkinsfiles

Ian Vernon
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!

--
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/0699e989-08e1-4134-8daa-e89192f2f4d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Trigger separate jobs with two distinct Jenkinsfiles

Victor Martinez
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.

--
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/2e86b76c-03c2-4fbd-a5b4-365b984e9f14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Trigger separate jobs with two distinct Jenkinsfiles

Ian Vernon
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?

On Wednesday, December 13, 2017 at 2:10:45 PM UTC-8, Victor Martinez wrote:
if the old tests will be deprecated and removed sooner than later, cannot you just use the <a href="https://jenkins.io/doc/pipeline/steps/pipeline-build-step/#build-build-a-job" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fdoc%2Fpipeline%2Fsteps%2Fpipeline-build-step%2F%23build-build-a-job\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGQ3DRxJLLKkyhU41MA5pxwmUS3fA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fdoc%2Fpipeline%2Fsteps%2Fpipeline-build-step%2F%23build-build-a-job\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGQ3DRxJLLKkyhU41MA5pxwmUS3fA&#39;;return true;">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.

--
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/efd618d2-3c61-4a4b-a2de-1f1258a3853f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Trigger separate jobs with two distinct Jenkinsfiles

stephenconnolly
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.


On Wed 13 Dec 2017 at 22:18, Ian Vernon <[hidden email]> wrote:
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?


On Wednesday, December 13, 2017 at 2:10:45 PM UTC-8, Victor Martinez wrote:
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.

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

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

Re: Trigger separate jobs with two distinct Jenkinsfiles

Victor Martinez
In reply to this post by Ian Vernon
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.

--
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/b8f2de16-46a1-42e6-9341-9f0394b6a741%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Trigger separate jobs with two distinct Jenkinsfiles

Ian Vernon
In reply to this post by stephenconnolly
Setting up two organization folders was the trick. Thanks!

On Wednesday, December 13, 2017 at 2:29:19 PM UTC-8, Stephen Connolly wrote:
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.

<a href="https://www.cloudbees.com/blog/watch-me-code-episode-4" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.cloudbees.com%2Fblog%2Fwatch-me-code-episode-4\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHoWly6p1xoXkLTlDwnfkWq4W43WQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.cloudbees.com%2Fblog%2Fwatch-me-code-episode-4\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHoWly6p1xoXkLTlDwnfkWq4W43WQ&#39;;return true;">https://www.cloudbees.com/blog/watch-me-code-episode-4

On Wed 13 Dec 2017 at 22:18, Ian Vernon <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="eQqMQfCkAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ianve...@...> wrote:
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?


On Wednesday, December 13, 2017 at 2:10:45 PM UTC-8, Victor Martinez wrote:
if the old tests will be deprecated and removed sooner than later, cannot you just use the <a href="https://jenkins.io/doc/pipeline/steps/pipeline-build-step/#build-build-a-job" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fdoc%2Fpipeline%2Fsteps%2Fpipeline-build-step%2F%23build-build-a-job\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGQ3DRxJLLKkyhU41MA5pxwmUS3fA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fdoc%2Fpipeline%2Fsteps%2Fpipeline-build-step%2F%23build-build-a-job\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGQ3DRxJLLKkyhU41MA5pxwmUS3fA&#39;;return true;">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.

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="eQqMQfCkAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/efd618d2-3c61-4a4b-a2de-1f1258a3853f%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/efd618d2-3c61-4a4b-a2de-1f1258a3853f%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/efd618d2-3c61-4a4b-a2de-1f1258a3853f%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/efd618d2-3c61-4a4b-a2de-1f1258a3853f%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.
--
Sent from my phone

--
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/eea15957-6a03-40df-af49-8a636214b689%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.