Trigger pipelines on pushing new tag
Trigger pipelines on pushing new tag in your repository.
You can set up your pipeline to automatically trigger whenever a new tag is pushed to your repository. This guide walks you through the steps to achieve this using a webhook trigger. Additionally, you can configure the trigger to load both the pipeline YAML and input sets from the same Git tag that triggered the execution, enabling version-controlled pipeline executions.
Pre-Requisite
Code repo connector that connects to your Git provider account.
Harness CI/CD Pipeline
Delegate version 26.04.89002 or later (required for Git tag-based pipeline and input set loading)
Steps to Trigger a Pipeline on a New Tag
In your Harness pipeline, create a webhook trigger and configure the Event type as Push.
When you create and push a new tag (e.g., v1) in your repository, Harness identifies it as a push event and triggers the configured pipeline.
Example: You push a tag v1 to the repository, which triggers the pipeline execution.

Other types of pushes (e.g., commits) can also trigger push events. To ensure your pipeline is only triggered when a new tag is pushed, you should configure payload conditions in the webhook trigger. In these cases you will need to add payload conditions to ensure your pipeline is only triggered on a tag push. For example:
Add a new condition, under Conditions -> Payload Conditions for your webhook trigger.
Set the payload's Attribute to
<+trigger.payload.ref>.Select Starts With as your Operator
For Matches Value, write
refs/tags.
Optionally, to filter for tag creation vs deletion, add another condition that checks to see if the tag was just created. For example:
Attribute:
<+trigger.payload.created>Operator:
EqualsMatches Value:
true
Add a new condition, under Conditions -> Payload Conditions for your webhook trigger.
Set the payload's Attribute to
<+trigger.payload.push.changes[0]['new']['type']>.Note: We recommend bracket notation here because
newcan be interpreted as a reserved keyword by the JEXL expression engine used to resolve these values.
Select Equals as your Operator.
For Matches Value, write
tag.
You can verify the payload received by the trigger in the Activity History section of the trigger. An example payload is shown below:
The ref field indicates the new tag, in this case, refs/tags/v1.
Load pipeline and input sets from Git tags
When using Git tag-based triggers, you can configure Harness to load both the pipeline YAML and input sets from the same Git tag that triggered the execution. This enables you to execute specific versions of your pipeline and input sets that are tagged in your repository, making it easier to maintain stable configurations alongside your release workflow and enabling reliable rollbacks to previous versions.
Using pipelineBranchName and inputSetBranchName with Git tags
You can add the pipelineBranchName and inputSetBranchName properties to your trigger YAML to specify the exact Git tag from which Harness should fetch the pipeline YAML and input sets when the trigger is activated.
To reference a Git tag, use the $tag: format:
$tag:<tag-name>- References a specific Git tag (for example,$tag:v1.0.0or$tag:release-2024.01)<+"$tag:"+<expression>>- References a Git tag using an expression that resolves at runtime to the tag name (for example,<+"$tag:"+<+trigger.tag>>resolves to the Git tag from the trigger payload)
Additional use cases
Load pipeline from a specific stable tag: Use
pipelineBranchName: $tag:v1.0.0to always execute a specific stable version of your pipelineLoad pipeline from tag, input set from branch: Mix tag and branch references to use a stable pipeline version with the latest input set configurations
For more information on using Git tags with pipelines and input sets, go to Git tag support for pipeline and input set source.
Last updated
Was this helpful?