Multi-branch pipeline without Jenkinsfile in the repo?

3,207 views
Skip to first unread message

Kaido Kert

unread,
Apr 29, 2017, 5:06:32 PM4/29/17
to Jenkins Users
Hi,

I've been using Freestyle multibranch project option for a long time to run multi-branch builds. However, it officially say's its deprecated now.
However, we do not have the freedom to stuff Jenkinsfile into all repositories/branches we want to build, and never will.

When i configure a pipeline multibranch build item, there is a Build Configuration: Mode dropdown in the UI, which frustratingly only offers 1 option: Jenkinsfile.
I'm guessing there is some plugin or mechanism to get more choices, such as pasted in script into this dropdown, but how ?

cheers,
-kert



Mark Waite

unread,
Apr 29, 2017, 7:46:32 PM4/29/17
to Jenkins Users


On Saturday, April 29, 2017 at 3:06:32 PM UTC-6, Kaido Kert wrote:
Hi,

I've been using Freestyle multibranch project option for a long time to run multi-branch builds. However, it officially say's its deprecated now.
However, we do not have the freedom to stuff Jenkinsfile into all repositories/branches we want to build, and never will.


If you aren't able to place a Jenkinsfile into the repositories / branches that you want to build, you might create a new (independent) repository which has one branch per repository and branch that you will build.  In each of the branches of that repository, you can add the Jenkinsfile and have it perform the checkout of the repository / branch that you're not able to change.  That allows you to have a repository with a branch per build (which is what multi-branch pipeline wants), and you can place a Jenkinsfile at the root of each branch to control what it is building.

That creates a "builders" repository where you control the Jenkinsfile, and that Jenkinsfile references the repositories and branches being built.

I used that technique to "test drive" a pipeline configuration for a component that wasn't ready to use Jenkins.  The official source repository didn't know that I was test driving, and I was able to make rapid progress without complaints about my Jenkins experiments.

Mark Waite

Kaido Kert

unread,
Apr 30, 2017, 3:46:57 PM4/30/17
to Jenkins Users
That


On Saturday, April 29, 2017 at 4:46:32 PM UTC-7, Mark Waite wrote:


On Saturday, April 29, 2017 at 3:06:32 PM UTC-6, Kaido Kert wrote:
Hi,

I've been using Freestyle multibranch project option for a long time to run multi-branch builds. However, it officially say's its deprecated now.
However, we do not have the freedom to stuff Jenkinsfile into all repositories/branches we want to build, and never will.


If you aren't able to place a Jenkinsfile into the repositories / branches that you want to build, you might create a new (independent) repository which has one branch per repository and branch that you will build.  In each of the branches of that repository, you can add the Jenkinsfile and have it perform the checkout of the repository / branch that you're not able to change.  That allows you to have a repository with a branch per build (which is what multi-branch pipeline wants), and you can place a Jenkinsfile at the root of each branch to control what it is building.

That creates a "builders" repository where you control the Jenkinsfile, and that Jenkinsfile references the repositories and branches being built.

I used that technique to "test drive" a pipeline configuration for a component that wasn't ready to use Jenkins.  The official source repository didn't know that I was test driving, and I was able to make rapid progress without complaints about my Jenkins experiments.

Mark Waite


 That would definitely solve the problem, i've done similar hooks to build CMake build trees for projects not intended to be built with it, etc.
However, it's a bit of a large overhead to just get 4-5 lines of minimal Jenkinsfile code to actually kick off the build, and especially when you are just tooling around and testing.

I've just actually gone through full Jenkins update to latest, and updated all plugins too, and now there is a new option, 'Default Jenkinsfile' which does seem to do what i need.

-kert

h1v...@gmail.com

unread,
Aug 8, 2017, 3:58:24 AM8/8/17
to Jenkins Users
Hi,

Sorry for resurrecting this thread. I have the same problem where the build pipeline is almost identical between projects, and the build pipeline and environment is controlled by build engineers, not the developers, so it's very tedious to put the same Jenkinsfile into tens of different repos AND having to update and create tens of pull requests when we have updates to build pipeline/environment.

I tried Mark Waite suggestion and it's fantastic. However, there's one big downside: sub-build created by each branch can not be setup to be triggered by BitBucket push. Has anyone be able to workaround this or have another strategy to solve the aforementioned problem? I did some research and saw this feature request (Set the bitbucket trigger using Declarative Pipeline) but it's not resolved yet and I don't know whether it could solve my problem.

Many thanks in advance,
Hai.

Leandro Nunes

unread,
Oct 2, 2017, 11:17:41 AM10/2/17
to Jenkins Users
Hi,

I´m also facing this scenario right now !
Currently I´ve just added a Jenkinsfile into each branch (it was so hard and tedious to change it and replicate over all branches =/)

This workflow doesn't look very sustainable, so I´ll configure this standalone repo strategy, suggested by Mark, that looks perfect,
but as I need automatic trigger by Github, I will face the problem Hai described.
I´m not sure if a cron strategy to build periodically could resolve this issue...

If anyone has some solution, please will be so welcome ! =)

Cheers

dhl...@triple-networks.com

unread,
Jan 16, 2018, 10:52:57 AM1/16/18
to Jenkins Users
Is it still possible to have this triggered on PR on the repository without the Jenkinsfile ?

Mark Waite

unread,
Jan 16, 2018, 10:59:12 AM1/16/18
to jenkins...@googlegroups.com
On Tue, Jan 16, 2018 at 8:52 AM <dhl...@triple-networks.com> wrote:
Is it still possible to have this triggered on PR on the repository without the Jenkinsfile ?


I don't think so.   Using a "shadow repository" with a Jenkinsfile is a temporary technique that I used while exploring Jenkins Pipeline.  

If you're ready to evaluate pull requests with Pipeline, I think you're ready to persuade the repository owners of the value of Jenkins Pipeline.

Mark Waite
 
--
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/458249a0-70b8-4e83-9f7a-a861fe0549a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jesse Glick

unread,
Jan 17, 2018, 1:45:44 PM1/17/18
to Jenkins Users
On Saturday, April 29, 2017 at 5:06:32 PM UTC-4, Kaido Kert wrote:
When i configure a pipeline multibranch build item, there is a Build Configuration: Mode dropdown in the UI, which frustratingly only offers 1 option: Jenkinsfile.
I'm guessing there is some plugin or mechanism to get more choices, such as pasted in script into this dropdown, but how ?

There is a multibranch defaults plugin which lets you pick a script from managed configuration files to apply regardless of the contents of the repository.

CloudBees Jenkins Enterprise includes another option¹ for which there is no direct OSS equivalent that I know of.

Reply all
Reply to author
Forward
0 new messages