Template Library Overview

Updated 5 days ago by Renu Bhaskaran

The Harness Template Library allows you to create re-usable logic and Harness entities (like steps and stages) in your Pipelines and share them with your teams. The Templates are scoped at the Account, Organization, or Project level.

Templates enhance developer productivity, reduce on-boarding time, are enforce standardization across the teams that use Harness.

This topic covers Template concepts.

Template Types

More Template types will be introduced shortly in upcoming releases.

Versioning

Versioning a Template enables you to create a new Template without modifying the existing one. When you plan to introduce a major change in a Project that depends on an existing Template, you can use versioning. You can create multiple versions of a Template.

When using a Template, you can either link to a specific version or always use the stable version. We recommend that you use the latter, as any changes made to the stable version automatically propagate to the Pipeline using the Template.

It is to be noted that, if incompatible changes are made to the template inputs, the Pipeline fails during execution.

Template Inputs

You can customize Templates by using placeholder expressions and Runtime Inputs for their parameters and data types. Each time you run a Pipeline that uses the Template, users can provide values for these inputs.

See Fixed Values, Runtime Inputs, and Expressions.

Template YAML

You can use the Harness visual or YAML editors to create your Templates.

Here's an example of the YAML for a CD Stage template:

template:
name: Quickstart
identifier: Quickstart
versionLabel: v1
type: Stage
projectIdentifier: CD_Examples
orgIdentifier: default
tags: {}
spec:
type: Deployment
spec:
serviceConfig:
serviceDefinition:
type: Kubernetes
spec:
variables: []
serviceRef: nginx
infrastructure:
infrastructureDefinition:
type: KubernetesDirect
spec:
connectorRef: docbuilds
namespace: default
releaseName: release-<+INFRA_KEY>
allowSimultaneousDeployments: false
environmentRef: helmchart
execution:
steps:
- step:
type: K8sRollingDeploy
name: Rolling
identifier: Rolling
spec:
skipDryRun: false
timeout: 10m
rollbackSteps: []
serviceDependencies: []
failureStrategies:
- onFailure:
errors:
- AllErrors
action:
type: StageRollback

The YAML editor is a full-fledged YAML IDE with autocomplete and other features. See Harness YAML Quickstart.

Activity Log

The Activity Log option lets you keep track of all Template events. It shows you details like who created the Template and Template version changes For example, adding a new version, setting a new default version, and configuration changes.

Git Sync Support

Harness Git Experience enables you to clone Templates in Git and then sync them with Harness. See Harness Git Experience.

RBAC Permissions Overview

You can set the RBAC permissions for Templates to enable access to authorized users. See Permissions Reference.

Template Editor

You can use the Open/Edit Template option and navigate to the Template Studio to edit the Template as per your needs. The editor allows you to perform the following actions:

  • Modify the name and version details of the Template
  • Set the Template version ( to stable or any other version)
  • View YAML file of the Template
  • Modify Step or Stage configurations

You can delete a Template using the Delete Template option. You can choose to delete either a specific version of the Template or all the versions.

It is to be noted that you can't delete a stable version of the Template and also a Template that has been been referenced in a Pipeline.


Please Provide Feedback