> 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-overview/v1-pipeline-template.md).

# Create a pipeline template

Define a reusable pipeline template in V1 pipelines, including inputs, and reference it from any pipeline.

A pipeline template defines a complete, reusable pipeline. Use it to standardize an entire pipeline structure across teams — for example, a canonical build-and-deploy pipeline, a security-scan pipeline, or a release pipeline — so every team starts from the same baseline and updates flow through everywhere the template is used.

***

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

* **V1 pipeline access:** A project with V1 pipelines enabled. Go to the [V1 pipelines overview](/harness-platform/3.0/in-harness-3.0/pipelines.md) to enable V1 in your project.
* **Secrets and connectors:** Any secrets the template references and a connector for each container image used by its steps. Go to the [secrets reference](/harness-platform/3.0/in-harness-3.0/secrets.md) and the [connectors reference](/harness-platform/3.0/in-harness-3.0/connectors.md) to configure them.
* **Permissions:** Create and Edit on Templates. Go to the [RBAC in Harness](/harness-platform/use-harness-platform/platform-access-control.md) to configure roles.

***

### Author the pipeline template <a href="#author-the-pipeline-template" id="author-the-pipeline-template"></a>

Define the template under the top-level `template` key with a `pipeline` block. The body of `pipeline` matches what you would write inside a regular V1 pipeline — stages, steps, and any other pipeline-level configuration.

```yaml
template:
  pipeline:
    stages:
      - name: stage_6e4d
        id: stage_6e4d
        steps:
          - name: run
            id: run
            run:
              script: echo 1
```

To make the template flexible at runtime, declare inputs under `template.inputs` and reference them inside the pipeline body with `<+inputs.<name>>`.

```yaml
template:
  inputs:
    image:
      type: string
      default: node:latest
    script:
      type: string
      required: true
  pipeline:
    stages:
      - name: build
        id: build
        steps:
          - name: run
            id: run
            run:
              container:
                image: <+inputs.image>
              script: <+inputs.script>
```

***

### Create the template in Harness <a href="#create-the-template-in-harness" id="create-the-template-in-harness"></a>

1. In your project, go to **Resources** and select **Templates**.
2. Select **New Template**. The **Select Template Type** dialog opens. Select **Pipeline Template**.
3. The **Create template** dialog opens. Fill in the following fields:
   * **Name** — a human-readable label for the template (for example, `pipeline-test`).
   * **Version label** — the version string consumers reference in `uses` (for example, `v1`).
   * **Storage** — where the template is stored. Select **Inline** to store it in Harness. To store it in a Git provider, select **Harness Code**, **GitHub**, **GitLab**, **Bitbucket**, **Azure Repos**, or **Git** and connect the relevant repository.
   * Optionally expand **Metadata** to add a description and tags.
4. Select **Start**. The template YAML editor opens.
5. Paste or author your pipeline template YAML in the editor, then save.

***

### Store the template <a href="#store-the-template" id="store-the-template"></a>

Choose where the template is versioned.

* **Harness-managed:** Save the template in the Harness platform. Versions are created and promoted in Harness.
* **Git-stored:** Commit the template to a Git repository. The Git tag, branch, or commit determines the resolved version.

Go to the [V1 Template Library overview](/harness-platform/3.0/harness-platform-resources/templates-overview.md) to compare storage modes.

***

### Reference the template from a pipeline <a href="#reference-the-template-from-a-pipeline" id="reference-the-template-from-a-pipeline"></a>

Reference a pipeline template by replacing the pipeline's `stages` with a top-level `template` block. Set `uses` to `<scope>.<name>@<version>` and supply input values under `with`.

```yaml
pipeline:
  template:
    uses: pipeline_test@v1
```

Because the template defines the entire pipeline body, a pipeline that references a pipeline template has no inline `stages`. All stages come from the template.

Pass input values through `with` when the template declares inputs.

```yaml
pipeline:
  template:
    uses: account.build-and-deploy@1.0.0
    with:
      image: node:20
      script: npm run build && npm test
```

If you omit the version suffix, the pipeline resolves to the latest stable version at execution time.

***

### Next steps <a href="#next-steps" id="next-steps"></a>

A pipeline template standardizes a complete pipeline. When you only need to share part of a pipeline, use a smaller template type instead. Go to the [stage template guide](/harness-platform/3.0/harness-platform-resources/templates-overview/v1-stage-template.md) to share a complete stage. Go to the [step template guide](/harness-platform/3.0/harness-platform-resources/templates-overview/v1-step-template.md) to share a single step. Go to the [step group template guide](/harness-platform/3.0/harness-platform-resources/templates-overview/v1-step-group-template.md) to share an ordered set of steps.
