Concepts

A template is a reusable piece of configuration that only exposes a minimal set of parameters to users, and is internally translated to a “standard” Jenkins configuration. Thus, a template can be used to expose a simplified, abstract, restricted representation of Jenkins job configuration to users. Changes to a template immediately apply to everywhere the template is used.

A template is conceptually broken down into a few pieces:

Model
A model defines a set of attributes that constitutes a template. Roughly speaking, you can think of this as a class of an object-oriented programming language. For example, if you are creating a template for your organization’s standard process of running a code coverage, you might create a model that has attributes like “packages to obtain coverage”, “tests to run.”
Attribute
An attribute defines a variable, what kind of data it represents, and how it gets presented to the users. This is somewhat akin to a field definition in a class definition.
Instance
An instance is an use of a model. It supplies concrete values to the attributes defined in the template. Roughly speaking, the model-to-instance relationship in the template plugin is like the class-to-object relationship in a programming language. You can create a lot of instances from a single template.
Transformer
A transformer is a process of taking an instance and mapping it into the “standard” Jenkins configuration, so that the rest of Jenkins understands this and can execute it. This can be logically thought of as a function.

When we say “template” it actually is a combination of a model and a transformer. And each facet of these concepts are individually extensible --- for example, additional transformers can be developed to let you express the transformation in the language of your choice.

Models

Models are hierarchical and can extend other models. This can be used to create some common usage templates, that are not designed for direct usage and will not be instantiable by users, and create concrete templates by specializing them for a dedicated task. When a model inherits another, it inherits all the attributes that are defined in the base model.

For example, a common utility template can handle connection and authentication to enterprise infrastructure, and child templates can use this basis to expose high-level tasks, like deploying a new release.

Template hierarchy is a useful way to manage templates growing complexity and mutualize attribute definition.

Template can be configured as being instantiable by users, or only a way to encapsulate some configuration to be used from other template by inheritance.

Templates have a dedicated entry in the top page, where the administrator will setup and maintain the templates.

All templates are based on generating Jenkins configuration from a reduced set of attributes, that the user will provide to apply the template for a dedicated job. This major complexity reduction makes configuring new jobs very simple for new users and reduce the risk of misconfiguration.

Attributes

Each attribute represents a fragment of data that constitutes a template, along with how it gets presented in the UI to the users. For example, you might define an attribute called "product code", which stores a string represented in the single-line text field.

Each attribute consists of the following data model:

ID
IDs uniquely identify an attribute among other attributes of the same model. ID is used to refer to an attribute in transformers and other places, so the characters you can use in ID are restricted.
Display Name
Display name is the human-readable name of the attribute. It is used for example when Jenkins present the configuration page to edit an instance.
Type
The type of the attribute primarily determines the type of the data that this attribute holds (such as String or boolean), but it also controls how the data is represented in the UI (for example, is it a single-line text field or a multi-line text area?). For the discussion of available attribute types, see the section called “Attribute Type Reference”.