DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • You Learned AI. So Why Are You Still Not Getting Hired?
  • Stop Using the ATM-Didn’t-Kill-Jobs Story to Reassure Developers About AI
  • 6 Books That Changed How I Think About Software Engineering in 2026
  • Accelerating Your Software Engineering Career With Open Source and Jakarta EE

Trending

  • MuleSoft IDP: Enhancing Efficiency and Accuracy in Data Extraction
  • What Is Plagiarism? How to Avoid It and Cite Sources
  • Feature Flag Debt: Performance Impact in Enterprise Applications
  • Run Gemma 4 on Your Laptop: A Hands-On Guide to Google's Latest Open Multimodal LLM
  1. DZone
  2. Culture and Methodologies
  3. Career Development
  4. Parameterize Jenkinsfile in MultiBranch Jobs

Parameterize Jenkinsfile in MultiBranch Jobs

Select different Jenkinsfiles as a parameter in MultiBranch Jobs

By 
Aytunc BEKEN user avatar
Aytunc BEKEN
·
Oct. 08, 21 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
15.5K Views

Join the DZone community and get the full member experience.

Join For Free

There is no need to spend time on telling how super useful the MultiBranch Job is in Jenkins. However, there is one drawback; You can define and use only one Jenkinsfile in a given repository which will be the default Jenkinsfile for all scanned branches.

As this may sound complicated, from time to time you may need to use different use Jenkinsfiles in the given repository for different purposes. In this case, your only option is to define different Pipeline Jobs with different Jenkinsfile and branch settings. 

Until now!

With the latest release of the Remote Jenkinsfile Provider plugin, it is possible to parameterize Jenkinsfile as an input ( String, choice, etc.. ) before running the child (Workflow/Branch) jobs which are discovered by scanning. For example, you can run Jenkinsfile1 for the master branch while you can run Jenkinsfile2 for another branch in the same repository! 

How To

For having this feature, please follow the steps below.

  1. Install the latest, newer than 1.18v, Remote Jenkinsfile Provider Plugin
  2. Store Jenkinsfiles in the repository. Do not forget to put default Jenkinsfile which is named Jenkinsfile. This file will be run once when a new branch is discovered by scanning.

    Jenkinsfile
  3. Put the below parameter section into all your Jenkinsfiles. As this parameter section will be processed when the job is run, the pipeline needs to have this for providing parameters screen on the next run!
    Please note that there is no restriction on using other parameters with the below one.

    JenkinsFileParameter
  4.  Configure MultiBranch job with Remote Jenkinsfile Provider.

    Build configuration Jenkins
  5. Save!

After saving the MultiBranch Job, It will scan the repository for branches ( If it doesn't scan automatically, do it manually ).

In the first discovery of a branch, default Jenkinsfile will run.

default jenkins

After the first run, child jobs will start asking for the Jenkinsfile parameter before running. 

You can select/provide Jenkinsfile name in the input section of each Workflow/Branch Job.

Pipeline test job

Selected/provided Jenkinsfile will run!

testfile Jenkins

Enjoy!

career

Opinions expressed by DZone contributors are their own.

Related

  • You Learned AI. So Why Are You Still Not Getting Hired?
  • Stop Using the ATM-Didn’t-Kill-Jobs Story to Reassure Developers About AI
  • 6 Books That Changed How I Think About Software Engineering in 2026
  • Accelerating Your Software Engineering Career With Open Source and Jakarta EE

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook