Overview
GitOps commands let you control Pipelines-as-Code directly from Git provider comments and commit messages. This creates a journal of all pipeline executions directly on your pull requests, next to your code. Available commands:/test- Run all or specific pipelines/retest- Retry failed pipelines/cancel- Cancel running pipelines/ok-to-test- Approve external contributor PRs- Custom commands via
on-commentannotation
Pull Request Commands
GitOps commands work on pull request comments (all providers) and pushed commits (GitHub, GitLab)./retest
Restart failed PipelineRuns or create new runs if none exist for the current commit.- Creates new runs if previous runs failed
- Creates new runs if no runs exist for the commit
- Skips if successful runs already exist (avoids duplicates)
/test
Run all matching PipelineRuns or a specific PipelineRun.my-pipeline-name PipelineRun.
Difference from /retest:
/testruns regardless of previous status/retestonly runs if previous runs failed or don’t exist
/ok-to-test
Allow external contributors to run CI by approving their PR.- Repository owner
- Repository collaborators
- Organization members
- Users in OWNERS file
- Users in Repository CR
policy.ok_to_test
Require SHA (GitHub Only)
Cluster admins can enforce SHA validation for/ok-to-test:
pipelines-as-code ConfigMap
- Short SHAs (7-40 chars) match HEAD commit prefix
- Full SHAs match exactly
/cancel
Cancel running PipelineRuns. Cancel all:
GitOps commands don’t work on closed pull requests or merge requests.
Pushed Commit Commands
- GitHub
- GitLab
Comment on commit to trigger commands:
How to comment:
How to comment:- Go to repository → Commits
- Click an individual commit
- Click a line number to add a comment
Branch Targeting
Commands on pushed commits target the latest commit (HEAD) of a branch. Default branch (no arguments):main, master).
Specific branch:
PipelineRun Configuration
For commit-based commands to work, the PipelineRun must be configured for push events on that branch:.tekton/push-pipeline.yaml
Commit in Multiple Branches
If a commit exists in multiple branches:- No branch specified: Uses the branch with the latest commit
- Branch specified: Uses that specific branch
Git Tag Commands
Trigger PipelineRuns on tagged commits. Supported: GitHub (App and Webhook), GitLab- GitHub
- GitLab
- Go to repository → Releases or Tags
- Click the tag (e.g.,
v1.0.0) - Navigate to the tagged commit
- Add a comment on the commit
.tekton/tag-release.yaml
The event type is
push for tag events. Configure on-event: "[push]" and on-target-branch: "[refs/tags/*]".Custom GitOps Commands
Create custom commands using theon-comment annotation.
Regex pattern to match comments
Example: Deploy Command
.tekton/deploy.yaml
Example: Merge PR Command
.tekton/merge-pr.yaml
Accessing the Trigger Comment
When a GitOps command triggers a PipelineRun, the{{ trigger_comment }} variable is set.
\n. Restore them in shell scripts:
Passing Arguments to Commands
Override dynamic variables or custom parameters:- Parameter must be defined as a custom parameter in Repository CR or be a standard dynamic variable
- Cannot pass arbitrary undefined parameters
Event Type Annotation
Thepipeline.tekton.dev/event-type annotation indicates which GitOps command triggered the run:
| Annotation Value | Description |
|---|---|
test-all-comment | /test (all pipelines) |
test-comment | /test <pipeline-name> |
retest-all-comment | /retest (all failed) |
retest-comment | /retest <pipeline-name> |
ok-to-test-comment | /ok-to-test |
cancel-all-comment | /cancel (all runs) |
cancel-comment | /cancel <pipeline-name> |
on-comment | Custom comment trigger |
{{ event_type }}:
For backward compatibility, {{ event_type }} returns pull_request for:
test-all-commenttest-commentretest-all-commentretest-commentok-to-test-comment
Non-Matching PipelineRun Trigger
GitOps commands can trigger PipelineRuns regardless of annotations:my-pipeline even if its annotations don’t match the current event.
Use case: Pipelines triggered only by comments, not automatic events.
.tekton/manual-deploy.yaml
Neutral Status on No Match
If/ok-to-test is used but no PipelineRuns match:
- GitHub: Neutral commit status posted (“No pipelines matched”)
- Allows other workflows (e.g., auto-merge) to proceed
Neutral status is only supported on GitHub.
Examples
Basic PR Workflow
Pushed Commit Workflow
Tag Release Workflow
Custom Deploy Workflow
Best Practices
metadata:
name: deploy-staging
annotations:
# Trigger with: /deploy-staging
pipelinesascode.tekton.dev/on-comment: "^/deploy-staging"
## GitOps Commands
- `/test` - Run all pipelines
- `/retest` - Retry failed pipelines
- `/deploy-staging` - Deploy to staging environment
- `/deploy-production` - Deploy to production
Troubleshooting
Command not triggering
Ensure user is authorized (see Running Pipelines - Authorization).
/retest not creating new runs
Expected behavior:/retest only runs if:
- Previous runs failed, OR
- No runs exist yet
Custom command not matching
Verify regex pattern:Next Steps
Event Matching
Configure comment-based triggers with on-comment annotation
Running Pipelines
Understand authorization and execution
Creating Pipelines
Use trigger_comment variable in PipelineRuns
Repository CRD
Configure authorization policies for ok-to-test
