Skip to content

A easy and seamless way to create and use templates in Jenkins.

License

Notifications You must be signed in to change notification settings

arpit-nagar/ez-templates-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Allows you to use any job as a template for another job with overridable parameters.

Creating a Template

Any Jenkins job can be used as a template

  • Select "Allow this job to be used as a template"

A template can be a fully runnable job in its own right or left disabled and used only as a parent for "real" jobs.

Using a Template

Any Jenkins job can inherit from a template of the same job type. The same job type is important, for example, if your template's job type is maven, then the new job type should also be maven.

  • Select "Use another job as a template" and enter the template's name
    • Ensure "Allow this job to be used as a template" is not checked
  • Click Apply. When you open the job after this, you will see the configuration copied in from the template. On the lower left, there will be a warning in red that this is job is controlled by the template.

How it works

The implementation overwrites its config with that of the template except the Parameters, which retain their default values, and items covered by specific flags.

Synchronisation happens whenever an implementation job or its template is saved.

Customizing the implementation

There are a few fields, however, that do not fully get synced. One of those is the Parameters section.

Whenever a template syncs:

  • New parameters added to the template are added to the implementation
  • Old parameters not in the template are removed from the implementation
    • ❗ Renaming a template parameter counts as a removal and addition - it is not synched as a "rename" and you will lose any customisation.
  • Existing parameters are synchronised
    • Default Values are not synced

Usecases

Not everything can be parameterised in a Jenkins job config. Here's a few sample uses

  • SCM Repository URL can be a param, allowing completely different projects to be built with the same template
    • Alternatively the param could simply the Git branch (e.g. master, feature)
  • Combined with NodeLabel plugin, implementations can specify build node requirements
    • e.g. Only build on Linux or boxes with IPv6
  • Parameterized Trigger and Conditional BuildStep plugins are the basis of many flexible configurations based on job parameters

About

A easy and seamless way to create and use templates in Jenkins.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 95.0%
  • HTML 2.2%
  • JavaScript 2.0%
  • CSS 0.8%