Use GitLab Event Triggers
TOC
OverviewCore FeaturesSupported Event TypesBasic Event InformationBasic Variables (Common to All Events)1. Push EventPush Event Variables2. Merge Request EventMerge Request Event Variables3. Comment EventsBasic Comment Event Variables (Common to All Comment Events)3.1 Merge Request Comment Variables3.2 Commit Comment VariablesConfiguration GuidePrerequisitesConfigure Webhook via GitLab UIPipeline Trigger Configuration ExampleOverview
GitLab Event Triggers allows you to automatically trigger Tekton pipelines through GitLab's Webhook events. It supports multiple event types, including code pushes, merge requests, comments, etc., enabling you to build a complete CI/CD automation workflow.
Core Features
- Multi-event Type Support: Supports various GitLab events such as Push, Merge Request, comments, etc.
- Standardized Trigger Binding: Provides standardized ClusterTriggerBindings to ensure consistency across platforms.
- Flexible Parameter Mapping: Automatically extracts key information from GitLab events for pipeline parameters.
- Secure Webhook Integration: Supports Webhook security verification.
Supported Event Types
Basic Event Information
All output variables can be used for pipeline parameter mapping. You can access parameter values using $(tt.params.<param name>).
Basic Variables (Common to All Events)
1. Push Event
Triggered when a developer pushes code to a GitLab repository. Suitable for:
- Continuous integration builds
- Automated deployment
- Code quality checks
Push Event Variables
2. Merge Request Event
Triggered when a merge request is created, updated, or closed. Suitable for:
- Automated code reviews
- Pre-release environment deployments
- Automated testing
Merge Request Event Variables
Refer to your GitLab instance's webhook documentation or GitLab's official merge request event documentation
3. Comment Events
Supports the following types of comments:
- Merge Request comments
- Commit comments
Suitable for:
- ChatOps comment automation
Basic Comment Event Variables (Common to All Comment Events)
3.1 Merge Request Comment Variables
3.2 Commit Comment Variables
Configuration Guide
Prerequisites
- An
EventListenerhas been created in the environment and is capable of processingTriggerin the target namespace. Please contact your platform administrator for more information. - GitLab can access the
EventListenermentioned above. - The required
Pipeline, as well as the necessary running configurations, have been created. - You have permissions to modify the Webhook settings of the GitLab project.
Configure Webhook via GitLab UI
- Visit your GitLab project settings.
- Navigate to Settings > Webhooks.
- Add a Webhook URL based on the deployment mode of
EventListener, for example, using thehttpsmode: - Choose the event types as needed:
- Push events
- Merge request events
- Comments
- (Optional) Configure the Secret Token.
- Click "Add webhook".
Pipeline Trigger Configuration Example
If the goal is to implement continuous integration through the trigger with the following requirements:
- Automatically trigger automated CI functionality upon code submission.
- Automatically trigger the CI pipeline when a merge request is opened.
To simplify this documentation, we assume the pipeline is ready with the following parameters provided:
Please replace with your actual pipeline information.
Next, we only need to configure the two triggers below:
Create Push Trigger
Save the following YAML as gitlab-push-trigger.yaml:
Create the resource in the environment:
Create Merge Request Trigger
Save the following YAML as gitlab-merge-request-trigger.yaml:
Please adjust the Interceptor configuration as needed.
Create the resource in the environment:
Validate Triggers
Validate by submitting code and creating a Merge Request.
CLI:
You can obtain the pipeline execution status using kubectl -n <namespace> get pipelinerun.
Console:
Access Pipelines > PipelineRuns to view the triggered pipelines.