7

Using Jenkins for multi-platform mutibranch builds.

I have multiple Multibranch Pipeline projects (one for each platform, since each platform requires notably different build steps). I have one code repository with multiple branches (which is why Multibranch Pipeline projects makes sense).

I would like to have each Multibranch Pipeline project reference a different Jenkinsfile, rather than all trying to use the one with the filename "Jenkinsfile" that is located in the root of the repository.

This resolved bug suggests that I should be able to do this, but I can't find any documentation outlining how to do this. Anyone know how I can go about doing this?

Thanks for your time! Allen

Allen Pestaluky
  • 3,126
  • 2
  • 20
  • 22
  • 1
    What version of Jenkins are you running? Since it was merged in so recently, maybe it just isn't in the version that you're using? – Kdawg Jul 18 '17 at 00:43
  • That was it! Updating the multibranch plugin from version 2.14 to 2.16 fixed my problem: I can now configure the jenkinsfile in my Build Configuration for my multibranch project! – Allen Pestaluky Jul 18 '17 at 15:48
  • Excellent! Also, I've been wanting this feature for a while, so I'm glad that I now know that this functionality exists. I'll add an answer indicating the exact version that this was added in. – Kdawg Jul 18 '17 at 16:11

1 Answers1

6

Upgrade the Pipeline Multibranch plugin to at least version 2.15. From the changelog at https://wiki.jenkins.io/display/JENKINS/Pipeline+Multibranch+Plugin:

2.15 (Jun 01, 2017)

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

After that, you can go to your project's configuration page and access the setting shown below:

Jenkinsfile path configuration

Community
  • 1
  • 1
Kdawg
  • 1,508
  • 13
  • 19
  • I noticed someone else actually had the same question. You're welcome to grab those Answer points here as well if you'd like: https://stackoverflow.com/questions/37272120/jenkins-workflow-multibranch-allow-for-specifying-jenkinsfile-path – Allen Pestaluky Jul 18 '17 at 17:24
  • 1
    Any ideas how to leverage this from a job-dsl multibranchPipelineJob definition? – Mark Gargan Nov 29 '17 at 16:08
  • if the desired name for the file was CheckmarxJenkinsfile then add this to the job-dsl for the multibranchPipelineJob configure { project -> (project / 'factory' / 'scriptPath') << 'CheckmarxJenkinsfile' } – Mark Gargan Dec 08 '17 at 12:19
  • Can you use environment variables inside that `Script Path`? I've tried `%BRANCH_NAME%/Jenkinsfile`, `BRANCH_NAME/Jenkinsfile`, etc. etc. to no avail. – Cole Apr 13 '18 at 16:06
  • @Cole try ${env.BRANCH_NAME} – Kevin Chen Aug 22 '18 at 21:59