Use a template
Harness enables you to add templates to create reusable logic and Harness entities (like steps, stages, and pipelines) in your pipelines. You can link these templates in your pipelines or share them with your teams for improved efficiency. Templates enhance developer productivity, reduce onboarding time, are enforce standardization across the teams that use Harness.
Harness templates also give you the option of reusing a pipeline templates to create a pipeline. You do not have to create a template all the time. Once you've created a template, you can reuse it to create multiple pipelines.
This topic explains how to use an existing pipeline template in a pipeline.
Before you begin
Step: Use a template
To use a pipeline template, do the following:
In Harness, select Deployments, and then select Pipelines.
Select Create a Pipeline.
Enter a Name for your pipeline, and then select Start with Template.
The next page lists all the available pipeline templates.
Select the template that you want to use.
You can filter the templates by scope. You can also use the search bar to search the template that you want to use.
In Details, you can see the following details about the selected template:
Type
Description
Tags
Version Label: Select the version label. Harness recommends using the Stable version of the template. This ensures that any changes that you make to this version are propagated automatically to the pipelines using this template.
In Template Inputs, you can view the number of step or stage inputs in that template.
Select YAML to view the YAML details of the template.
Select the Activity Log to track all template events. It shows you details, like who created the template and template version changes.
Select Use Template to use this template to create your pipeline.
Add the runtime input values (if required), and then select Save. The Pipeline is published successfully message appears.
You can also perform the following actions:
- Change template
- Remove template
- Open template in new tab
- Preview template YAML
After you've made all the changes, select Run, and then select Run Pipeline. The template is deployed.
Option: Copy to the pipeline
You must have the core_template_copy permission to copy a template.
You can also copy the contents of a specific template to your pipeline using the Copy to Pipeline option. This doesn't add any reference to the template. Copying a template to a pipeline is different from using a template for your pipeline. You can't change any step or stage parameters when you link to a template from your pipeline.
To copy your template to a pipeline, do the following:
In Harness, select the pipeline template that you want to copy.
In Template Inputs, select Copy to Pipeline.
In Create new Pipeline, enter a name, and then select Start.
Add a stage (if required).
Once you've made all the changes, select Save. You can Save Pipeline or Save as Template.
Select Run to deploy the template.