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

414 views
Skip to first unread message

Tom Brus

unread,
Jul 4, 2019, 8:51:15 AM7/4/19
to Jenkins Users
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

Daniel Butler

unread,
Jul 4, 2019, 9:39:00 AM7/4/19
to jenkins...@googlegroups.com
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

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

Tom Brus

unread,
Jul 5, 2019, 9:10:50 AM7/5/19
to Jenkins Users
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

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 <tom...@gmail.com> 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 jenkins...@googlegroups.com.

Ivan Fernandez Calvo

unread,
Jul 13, 2019, 7:27:55 AM7/13/19
to Jenkins Users
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

Reply all
Reply to author
Forward
0 new messages