GitLab Merge Request Trigger
See GitLab Triggers for an overview and Event Triggers for generic options like title, target, and if.
Placing the following snippet at the top of an RWX file will result in all tasks in the file running any time a GitLab merge request is opened, updated, or merged.
on:
gitlab:
merge-request:
It's common to pass values from the event as init parameters into tasks.
on:
gitlab:
merge-request:
init:
commit-sha: ${{ event.git.sha }}
base:
image: ubuntu:24.04
config: rwx/base 1.0.0
tasks:
- key: code
call: git/clone 2.0.3
with:
repository: [email protected]:YOUR_ORG/YOUR_REPO.git
ref: ${{ init.commit-sha }}
ssh-key: ${{ gitlab['YOUR_ORG/YOUR_REPO'].ssh-key }}
Event Fields
The following values are available in the event context for GitLab merge request triggers:
| Path | Description |
|---|---|
event.git.sha | The SHA of the commit that triggered the event. |
event.git.ref | The ref of the merge request. |
event.gitlab.merge-request.object_attributes.iid | The internal ID of the merge request. |
event.gitlab.merge-request.object_attributes.url | The URL of the merge request. |
event.gitlab.merge-request.object_attributes.title | The title of the merge request. |
event.gitlab.merge-request.object_attributes.action | The action that triggered the event (opened, reopened, updated, merged, closed). |
event.gitlab.merge-request.object_attributes.last_commit.message | The last commit message. |
event.gitlab.merge-request.object_attributes.last_commit.author.name | The last commit author name. |
event.gitlab.merge-request.object_attributes.source_branch | The source branch of the merge request. |
event.gitlab.merge-request.project.id | The ID of the GitLab project. |
event.gitlab.merge-request.project.path_with_namespace | The full path of the project (e.g., group/subgroup/project). |
event.gitlab.merge-request.project.web_url | The web URL of the project. |
event.gitlab.merge-request.user.id | The ID of the user who triggered the event. |
event.gitlab.merge-request.user.username | The username of the user who triggered the event. |
For all values available in the event.gitlab context for GitLab merge request triggers, see GitLab's documentation on merge request events.
Actions
By default, RWX fires the merge request trigger on [open, reopen, update]. If you only want to handle certain actions, you can specify them:
on:
gitlab:
merge-request:
actions: [open]
Note that merge is not a default action, as most teams will instead use a
push trigger on the base branch instead.
See GitLab's documentation on merge request events for a full list of available actions.