How to change the job template used by an instance?


The CloudBees Template Plugin doesn’t have a versioning mecanism and doesn’t allow to manage promotions and to incrementally apply a template change on all its instance.

Because of this if you change a job template all its instances will be updated at the same time when the template is saved.

A workaround is to manually manage versions of the template by creating different copies/updates (Template_V1, Template_V2, ) and to manually attach instances from a template to another.


  • CloudBees Jenkins Enterprise
  • CloudBees Template Plugin


This groovy script must be adapted to your usecase and executed in the script console.

This will allow you to configure the job Existing Job To Become Template Instance to use the template Name_of_Template_with_Underscores_Like_In_URL:

import com.cloudbees.hudson.plugins.modeling.ModelList
import com.cloudbees.hudson.plugins.modeling.impl.jobTemplate.InstanceFromJobTemplate
import com.cloudbees.hudson.plugins.modeling.impl.jobTemplate.JobPropertyImpl

def inst = new InstanceFromJobTemplate(ModelList.get().getItem('Name_of_Template_with_Underscores_Like_In_URL'))

Jenkins.instance.getItemByFullName('Existing Job To Become Template Instance')
  .addProperty(new JobPropertyImpl(inst)) // apply template
Have more questions? Submit a request


Please sign in to leave a comment.