Templating helps to create reusable workflows in order to make tasks like creating and maintaining branches, and managing large number of pipelines easier.
Creating Pipeline Templates
Pipeline Templates can be managed from the Templates tab on the Administration Page.
Clicking on the "Add New Template" brings up the following form which allows you to create a fresh template, or extract it from an existing pipeline. Once saved, the pipeline indicated will also start using this newly created template.
A template can also be extracted from a pipeline using the "Extract Template" link. This can be found on the "Pipelines" tab in the Administration page.
As an example, assume that there is a pipeline group called "my-app" and it contains a pipeline called "app-trunk" which builds the application from trunk. Now, if we need to create another pipeline called "app-1.0-branch" which builds 1.0 version of the application, we can use Pipeline Templates as follows
Using Administration UI
- Create a template "my-app-build" by extracting it from the pipeline "app-trunk", as shown in the previous section.
- Create a new pipeline "app-1.0-branch" which defines SCM material with the branch url and uses the template "my-app-build".
Power users can configure the above as follows:
<pipelines group="my-app"> <pipeline name="app-trunk" template="my-app-build"> <materials> <svn url="http://my-svn-url/trunk" /> </materials> </pipeline> <pipeline name="app-1.0-branch" template="my-app-build"> <materials> <svn url="http://my-svn-url/branches/1.0" /> </materials> </pipeline> </pipelines> <templates> <pipeline name="my-app-build"> <stage name="build"> <jobs> <job name="compile"> <tasks> <ant target="compile" /> </tasks> </job> </jobs> </stage> </pipeline> </templates>