kenorb
kenorb

Reputation: 166419

How to reuse Build Parameters across multiple Jenkins jobs?

I'm planning to reuse the same set of build parameters (like 10 of them) across dozens of jobs.

One way is to create a job, and clone it. But what if I want to change the build parameters at the later time when I have already hundred of similar jobs. Editing all of them one by one could be a nightmare.

Is there any way of managing parameterized projects?

As solution to this problem I would imaging some option or plugin where I can define global set of parameters and reuse them across my jobs.

Upvotes: 10

Views: 7168

Answers (7)

Rogério Peixoto
Rogério Peixoto

Reputation: 2247

How about EZ Templates Plugin (check also GitHub page)?

Just remember that when you create a template, that job shouldn't actually do anything else then being a template (meaning: you should not run that job) and put only the minimum common configs there, nothing else or things can get messy. That way you shouldn't have any problems.

Upvotes: 3

vaibhavnd
vaibhavnd

Reputation: 301

Using Parameterized Trigger Plugin you can save the properties in a property file and pass them across jobs. Then in you can override or use as is in the subsequent jobs.

Also this would help: Retrieve parameters from properties file.

Upvotes: 3

kenorb
kenorb

Reputation: 166419

Unfortunately mentioned Inheritance Plugin is not maintained anymore, it's buggy and it has some limitation such as Trigger Parameterized Builds cannot be implemented in Parent Projects, it's also difficult to override specific configuration and does not play well with Folders plugin.

Alternative ways are:

  • Job DSL Plugin which allows process jobs with DSLs which can be used as templates (a "seed" job), then run these DSL scripts into your jobs (read the tutorial). It's actively maintained on GitHub. For more advanced solutions you may use Pipelines instead.
  • Template Project Plugin which allows to set up a template project which has all the settings you want to share across your other jobs (by selecting use all the publishers from this project and pick the template project.

Upvotes: 4

mfidan
mfidan

Reputation: 647

Try Inheritence-Plugin which can help to solve the problem. We can read from plugin description:

Instead of having to define the same property multiple times across as many projects; it should be possible for many projects to refer to the same property that is defined only once. In other words, everything that is defined multiple times, but used in the same way, should be defined only once and simply referred to many times.

So to define the property only once across multiple jobs, you need to:

  1. Create a new job as Inheritance Project.
  2. You may set it as abstract project choose This build is parameterized.
  3. Add Inheritable Parameter and set it as Overwritable.
  4. After saving, set this project as parent, so parameters can be inherited.

jenkins-inheritance-plugin - Inheritable Parameter

Check the Jenkins Inheritance Plugin Tutorial Video for overview of the main features. See also GitHub page.

Unfortunately the plugin is not well maintained and it can be buggy when using with the latest Jenkins (e.g. #22885).

Upvotes: 2

Anand Jumnani
Anand Jumnani

Reputation: 65

You may manage this using single property file which can be injected in all the jobs

Upvotes: 0

abe
abe

Reputation: 341

You could also consider using Pipeline Global Library.

This plugin adds that functionality by creating a "shared library script" Git repository inside Jenkins. Every Pipeline script in your Jenkins see these shared library scripts in their classpath.

Upvotes: 2

Rogério Peixoto
Rogério Peixoto

Reputation: 2247

You could try using Configuration Slicing Plugin. This plugin allows you to perform mass configuration (including parameters) for a group of jobs.

Alternatively you could try writing a groovy management script to set the group of parameters to all those jobs at once. A good starting point would be this, note that this is just printing the current jobs parameters, you would have to alter that script to do want you want.

Upvotes: 5

Related Questions