Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Workflow Multibranch allow for specifying Jenkinsfile path

It seems like now you can only have a single Jenkinsfile in a single location in your project when using Multibranch type.

Is there a way to configure so I can place the Jenkinsfile somewhere else than in the root of the project under the name Jenkinsfile. There's hope, as there's an option of Fixed Configuration, maybe this is a feature for the future, but I would much appreciate the option, as in the current situation I do not have the option to run everything as one nicely compiled pipeline due to the size of the repo. I'm thinking of having multiple Jenkins jobs against the same repository.

-- Marcus

like image 400
Oldek Avatar asked May 17 '16 09:05

Oldek


People also ask

Where do I specify Jenkinsfile?

Using a text editor, ideally one which supports Groovy syntax highlighting, create a new Jenkinsfile in the root directory of the project. The stages directive, and steps directives are also required for a valid Declarative Pipeline as they instruct Jenkins what to execute and in which stage it should be executed.

How do I enable the Multibranch pipeline in Jenkins?

Head over to your Jenkins instance and create a new item. Enter a name for the job, and select the “Multibranch Pipeline” option at the end of the screen. Then, click on the OK button. In the next screen, go to the “Branch sources” tab, click on the “Add source” button, and choose “Git” from the dropdown menu.

What is the difference between pipeline and Multibranch pipeline in Jenkins?

Jenkins Pipeline Vs. Multibranch Pipeline. A multibranch pipeline is meant for building multiple branches from a repository and deploy to multiple environments if required. A pipeline job supports both pipeline steps to be added in Jenkins configuration and form SCM.

Which one enables you to implement different Jenkinsfile for different branches of the same project?

The Multibranch Pipeline project type enables you to implement different Jenkinsfiles for different branches of the same project. In a Multibranch Pipeline project, Jenkins automatically discovers, manages and executes Pipelines for branches which contain a Jenkinsfile in source control.


1 Answers

Starting with Pipeline: Multibranch plugin version 2.15, you can specify the Jenkinsfile location in your configuration.

See my answer at https://stackoverflow.com/a/45172149/2141666 and the plugin changelog at https://wiki.jenkins.io/display/JENKINS/Pipeline+Multibranch+Plugin. From the changelog:

2.15 (Jun 01, 2017)

JENKINS-34561 Option to select a script name/path other than Jenkinsfile.

like image 89
Kdawg Avatar answered Nov 02 '22 08:11

Kdawg