Skip to main content

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:

  1. In Harness, select your module or Productivity View, and then select Pipelines.

  2. Select + Create a Pipeline. The Create new Pipeline settings open.

  3. Enter a Name for your pipeline.

  4. (Optional) Select the pencil icon to enter a Description.

  5. (Optional) Select the pencil icon to add Tags.

  6. Select Start with Template.

    The next page lists all the available pipeline templates.

  7. 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.

  8. In 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.

    You can also select the version from within the pipeline after you have added the template.

    picture 0

  9. In Template Inputs, you can view the number of step or stage inputs in that template.

  10. Select YAML to view the YAML details of the template.

  11. Select the Activity Log to track all template events. It shows you details, like who created the template and template version changes.

  12. Select Use Template to use this template to create your pipeline.

  13. Add the runtime input values (if required), and then select Save. The Pipeline is published successfully message displays.

You can also perform the following actions:

  • Change template
  • Remove template
  • Open template in new tab
  • Preview template YAML

  1. After you've made all the changes, select Run, and then select Run Pipeline. The template is deployed.

Option: Copy to the pipeline

note

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:

  1. In Harness, select the pipeline template that you want to copy.

  2. In Template Inputs, select Copy to Pipeline.

  3. In Create new Pipeline, enter a name, and then select Start.

  4. Add a stage (if required).

  5. Once you've made all the changes, select Save. You can Save Pipeline or Save as Template.

  6. Select Run to deploy the template.

See also