how to define multibranch pipeline with jenkinsfile from another repository (or hardcoded)?

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

how to define multibranch pipeline with jenkinsfile from another repository (or hardcoded)?

tombrus
Hi,

I have a repos I want to build all branches for (repos-A).
I do not want to put any jenkinsfiles (or any other build related stuff) into this repos.
My jenkinsfile lives in a separate repos (repos-B).

So I need the branches from repos-A and I need the jenkinsfile to build with from repos-B.

How can I set this up?

- the Pipeline Multibranch Plugin only seems to allow "by Jenkinsfile" for mode
- the Multi-Branch Project Plugin is deprecated so I like to stay away from it
- I could live with a hardcaded jenkinsfile in the job itself

Any help welcome!
Tom Brus

--
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/a86e14e1-f39c-4616-92b0-957cdc3374c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to define multibranch pipeline with jenkinsfile from another repository (or hardcoded)?

Daniel Butler
You could use the Pipeline Multibranch Defaults plugin which does the hardcoded in the job approach

If a stub file in Repo-A is acceptable you could also use a shared library to store the actual jenkinsfile as a script and the stub just contains
doRepoBuild() or similar which is the way jenkins plugin builds share build scripting. The blog post https://jenkins.io/blog/2017/10/02/pipeline-templates-with-shared-libraries/ runs through a more elaborate example with a bunch of parameters to a similar end.

There are a few users which have done the parallel repo approach but I'm not myself sure of the details.

Regards,
Daniel

On Thu, Jul 4, 2019 at 1:51 PM Tom Brus <[hidden email]> wrote:
Hi,

I have a repos I want to build all branches for (repos-A).
I do not want to put any jenkinsfiles (or any other build related stuff) into this repos.
My jenkinsfile lives in a separate repos (repos-B).

So I need the branches from repos-A and I need the jenkinsfile to build with from repos-B.

How can I set this up?

- the Pipeline Multibranch Plugin only seems to allow "by Jenkinsfile" for mode
- the Multi-Branch Project Plugin is deprecated so I like to stay away from it
- I could live with a hardcaded jenkinsfile in the job itself

Any help welcome!
Tom Brus

--
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/a86e14e1-f39c-4616-92b0-957cdc3374c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CAO37hbiD6%3DQ5qMQy26KiFGVw4Q3hH%3DT4OVA%3DktvoDQYf5iAO1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to define multibranch pipeline with jenkinsfile from another repository (or hardcoded)?

tombrus
Thanks for the quick reply Daniel!

I am in the process of setting up an extra jenkins library repo and using the Pipeline Multibranch Defaults plugin as you indicated.
This way I do not need any stubs in Repo-A which is my preference.
It looks good until now, although it feels like a workaround in various ways.

I am a bit confused why these pipeline plugins lack some abviously useful features that seem pretty simple to implement:
  • Why does the Pipeline Multibranch plugin not have the two options that the Pipeline plugin has?
    • Pipeline Script (for script in the job)
    • Pipeline Script from SCM (for script from some SCM)
  • Why is there a separate Pipeline Multibranch Defaults plugin to only add that one extra option
  • Why can I only define a jenkins library in the root of a SCM-repo? (now I need to maintain an extra repo)
  • Why can I not include a declarative pipeline in another declarative pipeline? (seems simple, but there seem to be technical issues...)
Anyway, thanks again for the pointers and workaround, they are happily accepted!

Greetings,
Tom Brus


Op donderdag 4 juli 2019 15:39:00 UTC+2 schreef Daniel Butler:
You could use the Pipeline Multibranch Defaults plugin which does the hardcoded in the job approach
<a href="https://github.com/jenkinsci/pipeline-multibranch-defaults-plugin/blob/master/README.md" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fpipeline-multibranch-defaults-plugin%2Fblob%2Fmaster%2FREADME.md\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE9NhwzPkQ8IUBLpjhpl95sc2ygqg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fpipeline-multibranch-defaults-plugin%2Fblob%2Fmaster%2FREADME.md\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE9NhwzPkQ8IUBLpjhpl95sc2ygqg&#39;;return true;">https://github.com/jenkinsci/pipeline-multibranch-defaults-plugin/blob/master/README.md

If a stub file in Repo-A is acceptable you could also use a shared library to store the actual jenkinsfile as a script and the stub just contains
doRepoBuild() or similar which is the way jenkins plugin builds share build scripting. The blog post <a href="https://jenkins.io/blog/2017/10/02/pipeline-templates-with-shared-libraries/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fblog%2F2017%2F10%2F02%2Fpipeline-templates-with-shared-libraries%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9RZqxzvWKSBvqd8e9hk4CNvyUtg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fblog%2F2017%2F10%2F02%2Fpipeline-templates-with-shared-libraries%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9RZqxzvWKSBvqd8e9hk4CNvyUtg&#39;;return true;">https://jenkins.io/blog/2017/10/02/pipeline-templates-with-shared-libraries/ runs through a more elaborate example with a bunch of parameters to a similar end.

There are a few users which have done the parallel repo approach but I'm not myself sure of the details.

Regards,
Daniel

On Thu, Jul 4, 2019 at 1:51 PM Tom Brus <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="2TqlKw7VCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">tom...@...> wrote:
Hi,

I have a repos I want to build all branches for (repos-A).
I do not want to put any jenkinsfiles (or any other build related stuff) into this repos.
My jenkinsfile lives in a separate repos (repos-B).

So I need the branches from repos-A and I need the jenkinsfile to build with from repos-B.

How can I set this up?

- the Pipeline Multibranch Plugin only seems to allow "by Jenkinsfile" for mode
- the Multi-Branch Project Plugin is deprecated so I like to stay away from it
- I could live with a hardcaded jenkinsfile in the job itself

Any help welcome!
Tom Brus

--
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="2TqlKw7VCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkins...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/a86e14e1-f39c-4616-92b0-957cdc3374c1%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/a86e14e1-f39c-4616-92b0-957cdc3374c1%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a86e14e1-f39c-4616-92b0-957cdc3374c1%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/a86e14e1-f39c-4616-92b0-957cdc3374c1%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.

--
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/39f2d867-40b5-4d51-99c0-2d61fc929ea9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to define multibranch pipeline with jenkinsfile from another repository (or hardcoded)?

Ivan Fernandez Calvo
In reply to this post by tombrus
Hi,

There is an option by using a shared pipeline library that allows you to define a full pipeline in a step, so you can have a simple Jenkinsfile on the repos that only call those steps, in that way you manage all your pipeline in your pipeline shared library

--
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/4ecb51df-d02b-4347-8eed-a9ecc5e9710b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.