Trigger PAC Pipelines

For Regular Users

This page explains how PAC starts PipelineRuns after a repository is connected. To define the .tekton/ files that PAC selects, see Define PipelineRuns in Git.

PAC triggers pipelines in two ways:

  • Automatic event triggers: a Git provider sends webhook events, and PAC matches those events against annotations on PipelineRun files.
  • Comment command triggers: an authorized user comments with a PAC command such as /test, /retest, or /cancel.

Automatic Event Triggers

Automatic triggers are controlled by annotations in each PipelineRun under .tekton/. PAC reads the PipelineRun definitions from the Git ref that raised the event, matches the annotations, replaces PAC variables, and creates the matching PipelineRuns in the Repository namespace.

The table below explains which event source to use. For exact annotation syntax and examples, see Trigger Events.

Event sourcePAC eventMatch condition
Branch pushpushThe pushed branch matches the PipelineRun branch filter.
Tag pushpushThe tag ref matches the PipelineRun tag filter.
Pull Request / Merge Requestpull_requestThe PR/MR base branch matches the PipelineRun branch filter.
Label updatepull_requestThe PR/MR has a matching label condition.
Custom PR/MR commenton-commentThe new PR/MR comment matches the PipelineRun comment regular expression.

Use custom comment triggers for repository-specific commands such as /deploy-preview. Use the built-in PAC commands below when you want PAC's native rerun, test, cancel, or approval behavior.

For more matching options, see the Pipelines as Code event matching documentation.

Comment Command Triggers

PAC also recognizes built-in GitOps commands in comments. These commands are useful when you want to run, rerun, approve, or cancel pipelines without pushing another commit.

Commands on Pull Requests and Merge Requests

Use these commands on an open PR or MR:

CommandEffect
/testRun all matching PipelineRuns for the current PR or MR.
/test <pipelinerun>Run only the named PipelineRun.
/retestRerun matching PipelineRuns that have not already succeeded for the same commit.
/retest <pipelinerun>Rerun only the named PipelineRun.
/cancelCancel running PipelineRuns associated with the PR or MR.
/cancel <pipelinerun>Cancel only the named PipelineRun.
/ok-to-testAllow PAC to run CI for an external or otherwise untrusted contribution, when policy requires approval.
/ok-to-test <sha>Same as /ok-to-test, with explicit SHA validation when the PAC configuration requires it.

<pipelinerun> is the metadata.name or metadata.generateName value in the .tekton/ file, not the generated runtime name. For example, if the file has generateName: sv-event-pr-, use:

/test sv-event-pr-

Commands on Commit Comments

GitHub and GitLab support /test, /retest, and /cancel on comments added to a pushed branch commit. /ok-to-test is for PR/MR authorization and does not apply to pushed commits.

When you comment on a commit, PAC must know which branch or tag context to use. If you do not specify one, PAC uses the repository default branch. The commented commit must be the HEAD commit of that branch, or the commit pointed to by the tag.

Use branch:<branch> when the commit belongs to a non-default branch:

/test <pipelinerun> branch:<branch>

Use tag:<tag> when the command should run in a tag context. Tag comment commands are currently supported on GitHub App and GitHub webhook integrations only:

/test <pipelinerun> tag:<tag>

The same branch argument is accepted by /retest and /cancel. On supported GitHub tag comments, the tag argument is also accepted:

/retest <pipelinerun> branch:<branch>
/cancel <pipelinerun> branch:<branch>

Passing Parameters in Commands

Built-in commands can include key=value arguments. PAC parses them from the comment and can use them to override custom parameters defined in Repository.spec.params or supported standard variables:

/test <pipelinerun> environment=staging
/test <pipelinerun> message="run smoke tests"

Only parameters already defined for the Repository or recognized by PAC are applied. Arbitrary keys are ignored.

Provider Notes

AreaGitHubGitLab
PR/MR eventPull Request events map to pull_request.Merge Request events map to pull_request.
PR/MR commentsBuilt-in commands and on-comment work on open Pull Requests.Built-in commands and on-comment work on open Merge Requests.
Commit comments/test, /retest, and /cancel work on commit comments./test, /retest, and /cancel work on commit comments.
Tag comment commandstag:<tag> is supported with GitHub App and webhook integrations.tag:<tag> is not supported.
/ok-to-test <sha>SHA validation is used when the PAC configuration requires it.The command is supported for MR authorization; SHA validation is a GitHub-specific safeguard.

For more command details, see the Pipelines as Code GitOps commands documentation.

Verify a Trigger

After an event or comment is sent, check the PipelineRuns in the namespace where the Repository CR is defined:

kubectl get pipelineruns -n <namespace>

If no PipelineRun is created, check the event annotations and PAC controller logs:

kubectl logs -n <pac-namespace> -l app=pipelines-as-code-controller --tail=100

Common checks:

SymptomCheck
No run after a pushThe file is under .tekton/, on-event includes push, and on-target-branch matches the pushed ref.
No run after a PR or MR updateon-event includes pull_request, and on-target-branch matches the PR/MR base branch.
/test <pipelinerun> does not matchUse the name or generateName from the .tekton/ file, not the generated runtime PipelineRun name.
Commit comment does not runThe commented commit is the HEAD of the selected branch: or the commit pointed to by tag:.
on-comment does not runThe new comment matches the regular expression after trimming leading and trailing spaces.

Next Steps