GitLab Setup
Pipelines as Code supports GitLab through webhooks, providing full integration with GitLab merge requests and push events.Prerequisites
Before starting, ensure you have installed Pipelines as Code on your Kubernetes cluster.Create GitLab Personal Access Token
Create a personal access token for Pipelines as Code to interact with GitLab.Navigate to Personal Access Tokens
Follow GitLab’s guide to create a personal access token:
https://docs.gitlab.com/ee/user/profile/personal_access_tokens.htmlGo to: User Settings > Access Tokens
Configure token settings
- Token name:
pipelines-as-code-token - Expiration date: Set according to your security policy (30-90 days recommended)
- Scopes: Select
api
Token Scoping Considerations
Project-scoped tokens are more secure but have limitations with forked repositories:
- Can only access the upstream repository
- Cannot set status checks on fork source branches
- Pipeline status will fall back to merge request comments
- Can access multiple repositories including forks
- Enables status checks on both fork and upstream
- Better for environments with fork-based workflows
Working with Forked Repositories
Pipelines as Code supports merge requests from forked repositories with an automatic fallback mechanism:Status Reporting Fallback Chain
-
Primary: Attempt to set commit status on fork (source project)
- Requires: Token with write access to fork repository
- Result: Status appears in both fork and upstream UI
-
Fallback: Attempt to set commit status on upstream (target project)
- May fail if no CI pipeline exists for this commit in upstream
- Result: Status appears in upstream repository UI
-
Final Fallback: Post status as merge request comment
- Always works (requires MR write permissions)
- Provides same information as status checks
This design ensures status reporting works even with restricted token permissions.
Create Repository and Configure Webhook
There are two methods to set up the Repository and webhook:Automated Setup with tkn pac CLI
Manual Setup
Create webhook in GitLab
- Go to your GitLab repository
- Navigate to Settings > Webhooks
- Configure the webhook:
- URL: Your Pipelines as Code controller URL
- Secret token: Generate with
head -c 30 /dev/random | base64 - Trigger: Select these events:
- Push events
- Comments
- Merge request events
- Tag push events
- Click Add webhook
Troubleshooting Fork Merge Requests
Why Comments Instead of Status Checks?
Symptom: Pipeline status appears as MR comments instead of in the Pipelines tab. Cause: The GitLab token lacks write access to the fork repository. What happened:- Attempted to set status on fork → Failed (insufficient permissions)
- Attempted to set status on upstream → Failed (no CI pipeline entry)
- Fell back to MR comment → Succeeded ✓
This is working as designed. Comments provide the same pipeline information as status checks.
How to Get Status Checks
Choose the option that fits your security requirements:Option 1: Bot Account (Recommended for Production)
Grant permissions
- Read access: Upstream and fork repositories
- Write access: Fork repository (for status updates)
- CI pipeline access: Upstream repository
- Minimal permissions principle
- Clear audit trail (pipeline actions attributed to bot)
- No token rotation when team members change
Option 2: Group-scoped Token
Use a Group Access Token withapi scope.
Advantages:
- Simple to set up
- Works for fork and upstream repositories
- Broader permission scope
- May require GitLab Premium or Ultimate
Option 3: Accept Comment-based Status (Default)
Continue using project-scoped token with comment fallback. Advantages:- Most restrictive permissions
- No additional configuration needed
Disable All Comments
To disable status comments completely:Managing Webhooks and Tokens
Add Webhook to Existing Repository
Update Access Token
Using tkn pac CLI
Using kubectl
Find the secret name in your Repository CRD:Important Notes
- Self-hosted GitLab: Must specify
git_provider.urlin Repository CRD - Secrets: Must be in the same namespace as the Repository CRD
- Fork workflows: Consider token scope requirements for your workflow
- Comment strategy: Can be configured to control MR comment volume
Next Steps
After configuring GitLab:- Add
.tektondirectory with pipeline definitions to your repository - Test by creating a merge request or pushing commits
- Monitor pipeline status in the Pipelines tab or MR comments