Hi, Malte.

The "Jenkinsfile" is the marker file that Jenkins uses to find what
branches and PRs to build in a multibranch job. The Jenkinsfile tells
Jenkins 2 things: 1. I want to build this branch or PR. 2. The actual Job
to run.  Without a Jenkinsfile, Jenkins assumes that the branch needs to be
skipped.

The Jenkinsfile does need to be present but you have a lot flexibility
regarding what it contains. Using a Jenkinsfile there are ways to use an
alternative repository that defines the pipeline to run in various ways:

- The Remote Loader Plugin (
https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Remote+Loader+Plugin).
Using this plugin you can store your Pipeline script in any repository and
load it from your Jenkinsfile. The Jenkinsfile can be empty except for this
remote load. This will run the script for any branch that contains this
Jenkinsfile.

- The Global Library included in Jenkins with Pipeline. (
https://www.cloudbees.com/blog/jenkins-workflow-using-global-library-implement-re-usable-function-call-secured-http-endpoint).
With the global library you can create as many reusable Pipeline scripts as
you like. The name of the function becomes a global variable available
within any Pipeline script in Jenkins (including in Jenkinsfiles).  That
means you can create a method that has parameters or not and then simply
call that method from the Jenkinsfile.

You can use a combination of these two as well. So, yes, the Jenkinsfile
needs to be present but it doesn't have to contain your Pipeline script. It
can simply tell Jenkins where to find the Pipeline script that you want to
run.

This is a really brief answer but hopefully can get you on the right track.

Regards,
Patrick

On Wed, Apr 13, 2016 at 5:43 AM, <maltejac...@gmail.com> wrote:

> Hello,
>
> I have a question related to the new Pipeline Multi-branch Project:
>
> I have a lot of small repositories which share the same setup. Currently I
> use the JobDSL to automatically create new Jobs in Jenkins.
> In the future I would like to use the Multi Branch Pipeline project. I
> would use a JobDSL seed job to create a Multibranch Pipeline Project for
> each of my repositories (>#100, which all share the same setup!).
> But, since all should share the same setup, I do not want to store a
> _Jenkinsfile_ in each of the repositories. The Jenkinsfile should be used
> from a single source (e.g. another repository).
>
> My question: Can I use another source for the Jenkinsfile in a Pipeline
> Multi Branch Project than the Jenkinsfile in the repository itself?
> In a "normal" Pipeline project one can use a other source for the
> Jenkinsfile.
>
> Do I miss something or is it a missing feature?
>
> Thanks.
> Malte
>
> --
> 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-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/72d7249f-003c-43d5-afd6-4edef62defa1%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/72d7249f-003c-43d5-afd6-4edef62defa1%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Patrick Wolf
Sr. Product Manager
CloudBees

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAGDV0P8KZBZfyO8kFm3uAv56MdzyX3T_22htRKqbsL9s04zQdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to