Greg Dubicki
Greg Dubicki

Reputation: 6950

How to create a default configuration for each (new) Jenkins job?

During my long use of Jenkins I have come up with a set of defaults which I use for each new job, such as:

etc.

..but for now I set them up manually/copy an existing job as a template for a new one but that is obviously non-optimal.


I have looked for a plugin/setting that would enable me to configure the default setting for new jobs/global job settings that would override each job settings but I haven't found any solution yet.

Do you know how to do it?

Update

I have looked at Configuration Slicing Plugin but it's not clear to me whether this will help..

Update 2

I have just been reminded of Jenkins Job DSL / Plugin and I will look into its features soon but I am still interested in a simpler solution, with a lower entry level.

Upvotes: 5

Views: 3414

Answers (2)

KeepCalmAndCarryOn
KeepCalmAndCarryOn

Reputation: 9075

You could try the Job DSL which does the Dev Ops 'configuration as code' by building out your jobs (using another job)

The Jenkins "Job DSL / Plugin" is made up of two parts: The Domain
Specific Language (DSL) itself that allows users to describe jobs 
using a Groovy-based language, and a Jenkins plugin which manages 
the scripts and the updating of the Jenkins jobs which are created 
and maintained as a result.

Alternatively, the new way to do it is to define a pipeline (Jenkins 2.0) Which is a Jenkinsfile in the root of your repo

Jenkins Pipeline is a suite of plugins which supports implementing 
and integrating continuous delivery pipelines into Jenkins. Pipeline
provides an extensible set of tools for modelling simple-to-complex
delivery pipelines "as code" via the Pipeline DSL. 

Upvotes: 2

Claudiu
Claudiu

Reputation: 2164

The way I do this is by creating jobs with default options which only serve as templates. Then when creating a new job I select the option "Copy from" and write the name of the template job.

An even better solution would be to use something like inheritance - have a parent job which other jobs inherit, so if you want to add an option to all the jobs you would just need to add it to the parent job. The Inheritance plugin seems to do this, but unfortunately for me it interferes with other plugins and crashes when trying to configure it.

Upvotes: 0

Related Questions