Overview
Pipelines-as-Code uses policies to control which users can trigger PipelineRuns based on team membership in your Git provider organization. This provides an additional security layer beyond the standard repository permissions.Supported Providers: GitHub (App and Webhook) and Forgejo/Gitea. GitLab and Bitbucket do not currently support team-based policies.
How Policies Work
Policies are defined in the Repository CR underspec.settings.policy and define two main authorization actions:
- pull_request: Controls who can trigger CI on their own pull requests
- ok_to_test: Controls who can authorize external contributors to run CI
- Repository collaborators (users with direct access)
- Organization members
- OWNERS file specifications
- Team membership in the Git provider
Policy Configuration
Repository CR Setup
List of team names (from your Git provider organization) whose members can trigger CI on their own pull requests.Effect: Only members of these teams can automatically trigger PipelineRuns on their PRs, regardless of their repository role.
List of team names whose members can authorize external contributors to run CI by commenting
/ok-to-test on PRs.Effect: These users act as gatekeepers who can vouch for external contributions and allow them to run in your CI environment.Authorization Actions
pull_request Policy
Restricts who can trigger CI on pull requests:- Any repository collaborator can trigger CI
- Organization members can trigger CI
- Users in OWNERS file can trigger CI
- Only members of specified teams can trigger CI
- Repository owners still have access
- OWNERS file members still have access
- Other collaborators are blocked
This policy adds an additional restriction on top of existing repository permissions. It doesn’t grant new permissions.
ok_to_test Policy
Controls who can authorize external contributors:/ok-to-test- Approve this PR to run CI/test- Trigger specific tests (also requires authorization)/retest- Re-run failed tests only
Priority and Precedence
Theok_to_test policy takes precedence over pull_request policy:
- External contributor submits PR - CI doesn’t run
- Developer (in
developersteam) cannot approve - not inok_to_test - Lead (in
leadsteam) comments/ok-to-test- CI runs - Lead’s authorization applies to that PR going forward
OWNERS File Integration
The OWNERS file works alongside team policies:- Repository owners/admins - Always authorized
- OWNERS file members - Always authorized (both approvers and reviewers)
- Team policy members - Authorized if in specified teams
- Organization members/collaborators - Only if no policy is defined
Example: Combined OWNERS and Policy
Example: Combined OWNERS and Policy
- Alice, Bob: Can trigger CI on their PRs (OWNERS) AND approve external PRs (Alice is in ok_to_test)
- Core-team members: Can trigger CI on their own PRs
- Maintainers-team members: Can approve external contributor PRs
- Others: Blocked unless they’re repo owners
Use Cases and Examples
Open Source Project with External Contributors
Open Source Project with External Contributors
- Community member forks repo and submits PR
- CI doesn’t run automatically (security)
- Maintainer reviews code
- Maintainer comments
/ok-to-testif safe - CI runs for that PR
Internal Project with Restricted CI
Internal Project with Restricted CI
- Frontend engineer submits PR
- CI blocked (not in backend-engineers team)
- Backend lead reviews and comments
/ok-to-test - CI runs for the PR
Staging vs Production Environments
Staging vs Production Environments
GitOps Commands and Authorization
Policy settings affect these GitOps commands:| Command | Requires | Description |
|---|---|---|
/test | ok_to_test or PR author authorization | Run specified PipelineRuns |
/retest | ok_to_test or PR author authorization | Re-run failed PipelineRuns |
/ok-to-test | ok_to_test policy | Authorize external PR to run CI |
/cancel | PR author or ok_to_test | Cancel running PipelineRuns |
Team Name Resolution
PAC queries the Git provider API to resolve team membership: GitHub:- Team names are case-insensitive
- Use the team slug (URL-friendly name)
- Teams must be in the organization that owns the repository
- Subteams inherit parent team permissions
- Team names are case-sensitive
- Use exact team name as shown in the organization settings
- Teams must be in the organization that owns the repository
Team membership is checked at the time of the event (PR creation, comment, push). Changes to team membership take effect immediately on the next event.
Troubleshooting
User in Team But Still Blocked
User in Team But Still Blocked
Possible causes:
- Team name misspelled in Repository CR
- User not actually in the team (check Git provider)
- Team in wrong organization
- Team membership not synced yet
- Using team name instead of slug (GitHub)
ok-to-test Comment Not Working
ok-to-test Comment Not Working
Possible causes:
- Commenter not in
ok_to_testteam - Typo in command (must be exactly
/ok-to-test) - Comment edited after posting (use new comment)
- PAC webhook not configured
- Verify commenter is in the team
- Check PAC controller logs for authorization errors
- Ensure webhook events include
issue_comment
All Users Blocked Even Owners
All Users Blocked Even Owners
Cause: Repository owners and OWNERS file members should never be blockedCheck:
- Verify user has admin/maintain role on repository
- Check if OWNERS file is in the correct location (repository root)
- Review PAC controller logs for policy evaluation
Policy Not Taking Effect
Policy Not Taking Effect
Possible causes:
- Repository CR not in correct namespace
- Policy syntax error in YAML
- PAC controller not restarted after ConfigMap change
- Team doesn’t exist in the organization
Security Best Practices
- Principle of Least Privilege: Only add teams that truly need access
-
Separate ok_to_test Teams: Use a smaller, trusted team for
ok_to_testthanpull_request -
Review Before Approving: Always review code changes before commenting
/ok-to-test - Use OWNERS Files: Document trusted contributors in OWNERS files
- Audit Team Membership: Regularly review who’s in authorized teams
-
Monitor Approvals: Log and alert on
/ok-to-testusage - Different Policies Per Environment: Use stricter policies for production
- Document Policies: Maintain CONTRIBUTING.md explaining the authorization process
Limitations
See Also
- GitOps Commands - Using /ok-to-test and other commands
- Repository CRD - Complete Repository configuration
- Running PipelineRuns - How PipelineRuns are triggered
- GitHub Teams - GitHub team management