> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/harness-platform/3.0/harness-platform-resources/templates/use-a-template.md).

# 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](/harness-ai/use-harness-platform/templates/create-pipeline-template.md), you can reuse it to create multiple pipelines.

This topic explains how to use an existing pipeline template in a pipeline.

#### Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

* [Templates overview](/harness-ai/use-harness-platform/templates/template.md)
* [Create a pipeline template](/harness-ai/use-harness-platform/templates/create-pipeline-template.md)

#### Step: Use a template <a href="#step-use-a-template" id="step-use-a-template"></a>

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

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

#### Option: Copy to the pipeline <a href="#option-copy-to-the-pipeline" id="option-copy-to-the-pipeline"></a>

{% hint style="info" %}
You must have the **core\_template\_copy** permission to copy a template.
{% endhint %}

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.

### Advanced Options <a href="#advanced-options" id="advanced-options"></a>

When you create or edit a pipeline in Pipeline Studio by selecting a template, the **Advanced** tab separates template-level settings from pipeline-specific metadata (editable):

1. **Template-level settings**\
   These first four fields reflect what was defined under `advanced:` in your template:

   * **Pipeline timeout settings**
   * **Stage execution settings**
   * **Re-run settings**
   * **Delegate selector**

   By default, these fields are read-only and cannot be modified here. If the template owner allows a setting to be overridden, you can change that setting for this pipeline instance. Go to [Override template advanced settings](/harness-ai/use-harness-platform/templates/template-overrides.md) to understand how template overrides work.
2. **Pipeline metadata (editable)**\
   Below the read-only block you’ll find the only settings you can change for this pipeline instance:
   * [**Public access**](/harness-ai/use-harness-platform/pipelines/executions-and-logs/allow-public-access-to-executions.md)
   * [**Dynamic execution settings**](/harness-ai/use-harness-platform/pipelines/dynamic-execution-pipeline.md)

{% hint style="info" %}
Don’t overlook **Public access** and **Dynamic execution settings** – they’re the only editable controls in the Advanced tab when using a template.
{% endhint %}

### Template Details in Execution <a href="#template-details-in-execution" id="template-details-in-execution"></a>

When a pipeline uses templates, you can view the **template version used** during that particular execution directly in the **Execution view**.

{% hint style="info" %}
This feature is available behind the feature flag `PIPE_STORE_TEMPLATE_REFERENCE_SUMMARY_PER_EXECUTION`. Contact [Harness Support](mailto:support@harness.io) to enable it.

This information is available only for executions that start *after* the feature flag is enabled.

This is currently supported for pipeline, stage, step group, and step templates.
{% endhint %}

* In the **log view**, the **step-level details** display the template name and its `versionLabel`.
* In the **console view**, hovering over each step that uses a template shows a tooltip with the **template name and version**.
* In the **compiled YAML** view, the YAML contains both the fully resolved template content and the `template:` block. This is intentional: Harness re-attaches the template reference after resolution so you can audit exactly which template and version was used for that execution, even if the template changes afterward.

  ```yaml
  pipeline:
    identifier: run
    name: run
    template:
      templateRef: pipelineTemplate
      versionLabel: V1
      templateInputs:
        stages:
          - stage:
              identifier: shell
              type: Custom
              variables:
                - name: var1
                  type: String
                  value: testingInput
    stages:
      - stage:
          identifier: shell
          type: Custom
          name: shell
          spec:
            execution:
              steps:
                - step:
                    identifier: ShellScript_1
                    type: ShellScript
                    name: ShellScript_1
                    spec:
                      shell: Bash
                      source:
                        type: Inline
                        spec:
                          script: echo 1
                    timeout: 10m
    projectIdentifier: myProject
    orgIdentifier: default
  ```

  The `template:` block is the reference summary retained for auditing. The `stages:` block is the fully resolved content that was actually executed.

This helps you trace exactly which version of the template was used in a specific pipeline run, even if the template has changed afterward.

### See also <a href="#see-also" id="see-also"></a>

* [Create a step template](/harness-ai/use-harness-platform/templates/run-step-template-quickstart.md)
* [Create an HTTP step template](/harness-ai/use-harness-platform/templates/harness-template-library.md)
* [Create a stage template](/harness-ai/use-harness-platform/templates/add-a-stage-template.md)
