Using a Master Jenkinsfile for Multi-branch Pipelines

795 views
Skip to first unread message

Qazwart

unread,
Aug 19, 2016, 11:09:55 AM8/19/16
to jenkins...@googlegroups.com
I have just started looking at using Pipelines. One of the reasons I liked about Jenkins over CruiseControl was that Jenkins allowed you to quickly setup a build using a web form rather than attempting to setup up an entire process using an XML file. Pipelines feels a bit of a step back.

However, I am intrigued about multi-branch Pipelines which would allow use to create new Jenkins projects every time a new branch is created. No more copying and modifying config.xml files to create new jobs.

There are two issues. The first is that if you use Multi-branch Pipelines, there’s no way to browse the working directory, or allowing a user to scrub it if there’s an issue. The second is that I don’t want to maintain multiple Jenkinsfiles — one for each project. Most of my projects would be built using identical Jenkinsfiles. It would seem silly if I make a change in one, I would have to checkout and change 40 other Jenkinsfiles to get that same change.

So, is there a way to browse the working directory? If not, I can live with that. However, I’d like to know whether I can specify where a Jenkinsfile exist in a multi-branch Pipeline (I can do that with other types of Pipeline projects), or somehow read in a master Jenkinsfile from another Jenkinsfile in another project. I could create a local Jenkinsfile whose sole purpose is to call in the real Jenkinsfile.

Thanks.

Sverre Moe

unread,
Aug 22, 2016, 6:56:36 AM8/22/16
to Jenkins Users
Take a look at Pipeline Global Library
https://github.com/jenkinsci/workflow-cps-global-lib-plugin/blob/master/README.md

You can maintain all build logic within a global build script which is called from within each Jenkinsfile. You would still need a Jenkinsfile within each repository on all branches you wish to build, but you can keep a minimal content in each Jenkinsfile.
Reply all
Reply to author
Forward
0 new messages