> 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/continuous-delivery/use-continuous-delivery/cd-building-blocks/templates/create-a-remote-step-template.md).

# Create a remote step template

This topic explains how to create a remote step template in Harness.

{% hint style="info" %}
**Remote step templates require a feature flag**

This feature is behind the feature flag `NG_TEMPLATE_GITX`. Contact [Harness Support](mailto:support@harness.io) to enable it.
{% endhint %}

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, and enforce standardization across the teams that use Harness.

You can create a template and save it either in Harness or in a Git repository, using the **Inline** or **Remote** option respectively.

This topic walks you through the steps to create a Remote step template.

![Create New Step Template settings showing the Inline and Remote options](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-0454fdaace3d93ef46605dda98c4beaeaa87a4e6%2Fcreate-a-remote-step-template-16.png?alt=media)

***

## What you will learn from this topic

* **Create a Remote Run step template:** How to save a step template to a Git repository instead of inline in Harness.
* **Define template parameters:** How to configure input and output variables for the step template.

***

## Before you begin

* **Harness key concepts:** Go to [Harness key concepts](https://developer.harness.io/harness-platform/new-to-harness-platform/overview) for the platform concepts this topic assumes.
* **Templates overview:** Go to [Templates overview](https://developer.harness.io/harness-platform/use-harness-platform/templates/template) for background on inline and remote templates.
* **Templates permissions:** You need **Create/Edit** and **Access** permissions for templates. To get these, an administrator must assign you a role that includes them.

***

## Remote step template overview

Harness templates let you design reusable content, logic, and parameters, so the application stays the main focus of your pipelines. Instead of creating pipelines from scratch each time, Harness lets you select from pre-built templates and link them to your pipelines. This reduces duplication and increases reusability.

You can share your work with your team and reuse it across your pipelines.

All your templates appear in **Templates** based on their scope. This topic also refers to this as the template library.

Harness lets you save your templates in Git repositories. For example, if you have a core step that you want all of your pipelines to use, you can put the template in a core repository and then reference it from multiple pipelines.

For information on inline step templates, go to [Create a step template](https://developer.harness.io/harness-platform/use-harness-platform/templates/run-step-template-quickstart).

***

## Use a template in a pipeline

Harness resolves the repositories when your pipeline starts up. After that, the same resource is used during the execution of the pipeline. Whenever you use templates in your pipelines, once the templates are fully expanded, the final pipeline runs as if it were defined entirely in the source repository.

You can have one of the following scenarios when using a template in your pipeline:

* Remote step template and the pipeline exist in the same Git repository.
* Remote step template and the pipeline exist in different Git repositories.
* Pipeline exists in Harness and the step template exists in a Git repository.

The following sections describe how to use a template in each of these situations.

**Remote step template and the pipeline exist in the same Git repository**

To use the template in your pipeline when your Remote step template and pipeline are both present in the same Git repository, make sure your pipeline and template are both present in the same branch.

**Remote step template and the pipeline exist in different Git repositories**

To use the template in your pipeline when your Remote step template and pipeline are present in different Git repositories, make sure your template is present in the default branch of its repository.

**Pipeline exists in Harness and the step template exists in a Git repository**

To use the template in your inline pipeline, make sure your template is present in the default branch of your Git repository.

***

## Create a remote step template

You can create a step template from your account, org, or project. This topic explains the steps to create a step template from the project scope.

{% stepper %}
{% step %}

### Open the template library

In your Harness account, go to your project. In **Project Setup**, select **Templates**.
{% endstep %}

{% step %}

### Start a new step template

Select **New Template**, and then select **Step**. The **Create New Step Template** settings appear.

![Create New Step Template settings](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-7f91ad02128503d81803ec29be19f8e32d50dd6b%2Fcreate-a-remote-step-template-17.png?alt=media)

In **Name**, enter a name for the template. In **Version Label**, enter a version for the template. Select **Remote**.
{% endstep %}

{% step %}

### Configure the Git connector

In **Git Connector**, select or create a Git connector to the repository for your project. For steps, go to [code repository connectors](https://developer.harness.io/harness-platform/use-harness-platform/connectors/code-repositories/ref-source-repo-provider).

{% hint style="warning" %}
**Connector requires API access**

The connector must use the Enable API access option and Username and Token authentication. Harness requires the token for API access. Generate the token in your account on the Git provider, and add it to Harness as a secret. Then use the token in the credentials for the Git connector.
{% endhint %}

![Enable API access option on the Git connector](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-36e33e3ddba114d0c7856eafa49b52293313c85f%2Fcreate-a-remote-step-template-18.png?alt=media)

For GitHub, the token must have the following scopes:

![Required GitHub token scopes for the Git connector](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-7cc582a3dc10c19696b8897ba9b87709abd6d7f0%2Fcreate-a-remote-step-template-19.png?alt=media)
{% endstep %}

{% step %}

### Select the repository and branch

In **Repository**, select your repository. If your repository is not listed, enter its name, because only a select few repositories are filled in here. Create the repository in Git before entering it in **Select Repository**. Harness does not create the repository for you.

In **Git Branch**, select your branch. If your branch is not listed, enter its name, because only a select few branches are filled in here. Create the branch in your repository before entering it in Git Branch. Harness does not create the branch for you.
{% endstep %}

{% step %}

### Set the YAML path and start

Harness auto-populates the **YAML Path**. You can change this path and the file name.

Select **Start**. Your step template is created, and you can now add steps from the step library.

![Step template created and ready for steps from the step library](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-49b1197b67539b14e72d5883e65d582417ef71e4%2Fcreate-a-remote-step-template-20.png?alt=media)
{% endstep %}
{% endstepper %}

***

## Add step parameters

{% stepper %}
{% step %}

### Add a Shell Script step

In **Step Library**, select **Shell Script** under **Utilities**. The **Step Parameters** settings appear.

In **Script**, enter your script. Specify your **Input Variables** and **Output Variables**.

In **Execution Target**, specify where you want to execute the script. You can select **Specify on Target Host** or **On Delegate**. For more information, go to [Using Shell Scripts in CD Stages](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/utilities/shell-script-step.md).
{% endstep %}

{% step %}

### Save the template to Git

Select **Save**. The **Save Template to Git** settings appear.

![Save Template to Git settings](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-c0a96bf8d60c51bd9f6e3a891102e383935ed938%2Fcreate-a-remote-step-template-21.png?alt=media)

In **Select Branch to Commit**, select one of the following:

* **Commit to an existing branch**: You can start a pull request if you want.
* **Commit to a new branch**: Enter the new branch name. You can start a pull request if you want.

Select **Save**. Your step template is saved to the repository branch.

![Step template saved to the Git repository branch](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-b9f5f2be4952938bc2d7abcb7d8e027ccc13572a%2Fcreate-a-remote-step-template-22.png?alt=media)
{% endstep %}

{% step %}

### Edit the template in Git

Select the YAML file to see the YAML for the step template. Edit the YAML, for example change the name of the template, and commit your changes to Git.

Return to Harness and refresh the page. A **Template Updated** message appears.

![Template Updated message in Harness after a Git commit](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-044ff5706952c351aedc4d7d5c08bf3a25692182%2Fcreate-a-remote-step-template-23.png?alt=media)

Select **Update**. The changes you made in Git are now applied to Harness.
{% endstep %}
{% endstepper %}

***

## Next steps

You have created a Remote step template and defined its parameters. For related tasks, go to:

* [Use a template](https://developer.harness.io/harness-platform/use-harness-platform/templates/use-a-template): Link the template to a pipeline, stage, or step.

{% @harness-feedback/feedback %}
