|
| 1 | +// This module is included in the following assembly: |
| 2 | +// * pac/managing-pipeline-runs-pac.adoc |
| 3 | + |
| 4 | +:_mod-docs-content-type: CONCEPT |
| 5 | +[id="op-triggering-`pipelinerun`-on-git-tags-using-pipelines-as-code_{context}"] |
| 6 | += Triggering a `PipelineRun` on Git tags |
| 7 | + |
| 8 | +[role="_abstract"] |
| 9 | + |
| 10 | +When you create or reference a Git tag in a repository that is integrated with {pac}, you can trigger a `PipelineRun` that corresponds to the commit associated with that tag. This capability enables you to test or deploy tagged versions of your code, supporting release-based workflows and version control practices. |
| 11 | + |
| 12 | +{pac} resolves the Git tag to its corresponding commit SHA and runs the `PipelineRun` defined for that commit. You can initiate or manage such runs by commenting on the tagged commit using supported GitOps commands. |
| 13 | + |
| 14 | +Triggering `PipelineRun` on Git tags is supported for GitHub App, GitHub Webhook, and GitLab integrations. This functionality is not currently available for Gitea, Bitbucket Cloud, or Bitbucket Data Center. |
| 15 | + |
| 16 | +You can use GitOps comment commands to interact with `PipelineRun` associated with a Git tag. Each command applies to either all `PipelineRun` for the tag commit or to a specific `PipelineRun` name. For example, `/test tag:<tag>` retriggers all `PipelineRun` that match the tag commit, while `/test <`pipelinerun`-name> tag:<tag>` retriggers only the specified `PipelineRun`. Similarly, `/retest` and `/cancel` commands can be used with or without a specific `PipelineRun` name to rerun or cancel `PipelineRun` related to the tagged commit. These commands provide fine-grained control over `PipelineRun` triggered by tagged commits. |
| 17 | + |
| 18 | +A `PipelineRun` configured to respond to tag events typically includes annotations such as `pipelinesascode.tekton.dev/on-target-branch: "[refs/tags/*]"` and `pipelinesascode.tekton.dev/on-event: "[push]"`. These annotations ensure that tag creation events are recognized as push events and processed correctly. When a tag is created or referenced, {pac} treats it as a push event and uses the resolved commit SHA to run the associated `PipelineRun`. The same logic applies to subsequent GitOps commands added as comments on the tagged commit. |
| 19 | + |
| 20 | +Tag based triggering is particularly useful in continuous delivery scenarios where specific versions or releases are represented by tags. This method enables you to validate and promote release artifacts consistently without modifying the branch state. |
| 21 | + |
| 22 | +The following example shows a minimal `PipelineRun` configuration that triggers on tag events: |
| 23 | + |
| 24 | +[source,yaml] |
| 25 | +---- |
| 26 | +apiVersion: tekton.dev/v1beta1 |
| 27 | +kind: PipelineRun |
| 28 | +metadata: |
| 29 | + name: pipelinerun-on-tag |
| 30 | + annotations: |
| 31 | + pipelinesascode.tekton.dev/on-target-branch: "[refs/tags/*]" |
| 32 | + pipelinesascode.tekton.dev/on-event: "[push]" |
| 33 | +spec: |
| 34 | + pipelineSpec: |
| 35 | + tasks: |
| 36 | + - name: tag-task |
| 37 | + taskSpec: |
| 38 | + steps: |
| 39 | + - name: echo |
| 40 | + image: registry.access.redhat.com/ubi9/ubi-micro |
| 41 | + script: | |
| 42 | + echo "tag: {{ git_tag }}" |
| 43 | +---- |
| 44 | + |
| 45 | +To trigger this PipelineRun from GitHub, open your repository and navigate to the *Tags* view or the *Releases* section. Click the tag, for example `v1.0.0`, to view its associated commit. Add a comment on that commit using one of the supported commands such as `/test tag:v1.0.0` or `/cancel tag:v1.0.0`. |
| 46 | + |
| 47 | +Tag-based triggering is particularly useful in continuous delivery scenarios where specific versions or releases are represented by tags. |
0 commit comments