Configure GitLab Repository
This guide connects a GitLab repository to PAC: prepare the credentials, create the Repository resource, register the webhook, and trigger a PipelineRun.
GitLab uses Webhook mode. A GitLab access token and a project webhook are configured per repository.
This page uses manifests and the GitLab Web UI. For the CLI workflow, see tkn pac Command Reference.
TOC
PrerequisitesStep 1: Create a GitLab Access TokenStep 2: Create the Kubernetes SecretStep 3: Create theRepository resourceStep 4: Register the webhook in GitLabStep 5: Add a PipelineRun and trigger itVerificationTroubleshootingNext stepsPrerequisites
- PAC component deployed and exposed to GitLab; see Manage PAC Component.
- The PAC webhook URL; see Get the PAC Webhook URL.
- Maintainer access to the GitLab project (required to add a webhook).
- A target Kubernetes namespace where the
Repositoryresource and itsPipelineRuns will live. kubectlaccess to that namespace.
Step 1: Create a GitLab Access Token
PAC needs a token to read project metadata, post merge request comments, and update commit status. A Personal Access Token or a Project Access Token both work.
- In GitLab, open the project or your user Settings → Access Tokens.
- Create a token with:
- Name: a descriptive name, for example
pac-integration. - Scopes:
api.
- Name: a descriptive name, for example
- Copy the token. GitLab shows it only once.
Step 2: Create the Kubernetes Secret
Create one Secret carrying the GitLab token and a webhook secret. Follow Create a Git Secret for PAC.
In the rest of this guide the Secret is named gitlab-webhook-config.
Step 3: Create the Repository resource
The Repository references the Secret. For GitLab.com:
For self-hosted GitLab, set spec.url to the project URL and add git_provider.url with the GitLab instance base URL:
For self-hosted GitLab, git_provider.url must be the GitLab instance base URL, not the project URL.
Apply it:
Verify:
Example output:
Step 4: Register the webhook in GitLab
- Open the GitLab project, then Settings → Webhooks.
- Click Add new webhook.
- Fill in the form:
- URL: the PAC webhook URL from the prerequisites.
- Secret token: the same
webhook.secretvalue stored in the Kubernetes Secret. - SSL verification: enabled (recommended; uncheck only for non-production setups with self-signed certificates).
- Under Trigger, check:
- Push events (with All branches unless you want to restrict)
- Tag push events
- Comments
- Merge request events
- Click Add webhook.
GitLab offers a Test → Push events action under the webhook entry. A 200 response confirms the controller received and accepted the event.
Step 5: Add a PipelineRun and trigger it
Add a PipelineRun manifest under .tekton/ in the repository and push it. PAC reads the file from the branch the event was raised on, matches the annotations against the event, and creates a PipelineRun in the namespace.
See Define PipelineRuns in Git for the file layout and the annotation grammar, and Trigger Pipelines for the Git operations that PAC reacts to.
Verification
After a Git event arrives, PAC creates a PipelineRun in the Repository's namespace. Confirm:
The PAC controller logs show the event being processed:
GitLab displays the commit status set by PAC on the relevant pipeline / merge request page.
Troubleshooting
For the full troubleshooting matrix, see Common Issues.
Next steps
- Define PipelineRuns in Git — define and evolve pipelines under
.tekton/. - Trigger Pipelines — push, merge request and comment-driven triggers.
- Advanced Repository Configuration — concurrency, parameters, custom settings.
- Configure Custom Certificates — for self-hosted GitLab with a private CA.