Jenkins Workflow Multibranch lets you specify the Jenkinsfile path

It seems that now you can have only one Jenkins file in one place in your project when using the Multibranch type.

Is there a way to customize, so I can place the Jenkinsfile somewhere else than in the root of the project called Jenkinsfile. There is hope, since there is the Fixed Configuration option, perhaps this is a function for the future, but I would really appreciate this opportunity, since in the current situation I do not have the ability to run everything as one well-compiled pipeline due to the repo size. I think that I have several Jenkins jobs against the same repository.

- Marcus

+5
source share
2 answers

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

See my answer at fooobar.com/questions/1249322 / ... and in the plugin change list https://wiki.jenkins.io/display/JENKINS/Pipeline+Multibranch+Plugin . From the change log:

2.15 (June 01, 2017)

JENKINS-34561 Ability to select script name / path other than Jenkins file.

+5
source

I think I ran into a similar problem.

What you can do is have a different pipeline file stored somewhere else. It can be in one place of check or other check together.

You can define methods in this file, and you need to close "return this" so that the beginning Jenkins file can use the second script. Example:

def initialize(){ wrap([$class: 'BuildUser']) { env.buildUserName = "$env.BUILD_USER" env.buildUserId = "$env.BUILD_USER_ID" env.buildUserEmail = "$env.BUILD_USER_EMAIL" } } // Has to exist with 'return this;' in order to be used as library return this; 

In the Jenkins file, you can do the following:

 def steps node { steps = load 'MyJenkinsPipelineScript.groovy' steps.initialize() } 

Based on any environment variables, you can upload different files. Hope this helps.

+1
source

All Articles