# Gitlab Merge Request<no value>

// <!-- Required for asciidoctor -->
:toc:
// Set toclevels to be at least your hugo [markup.tableOfContents.endLevel] config key
:toclevels: 4

== Description

The `gitlab/mergerequest` action opens (or updates) a link:https://docs.gitlab.com/ee/user/project/merge_requests/[GitLab merge request] once a target linked to the same scm has changed something and the change has been pushed.

It is the second half of the GitLab workflow: the link:/docs/plugins/scm/gitlab/[`gitlab` scm] commits to a working branch and pushes it, this action turns that branch into a merge request. Without it, the branch is pushed and nothing else happens.

The scm may be either `gitlab` or link:/docs/plugins/scm/gitlabsearch/[`gitlabsearch`]; with the latter, one merge request is opened per discovered project.

== Requirements

include::content/en/docs/plugins/_actionScm.adoc[]

== Parameters

{{< resourceparameters "actions" "gitlab/mergerequest" >}}

=== Assignees and reviewers

`assignees` and `reviewers` take *numeric GitLab user IDs*, not usernames - a list of integers. To find one, open the user's profile page, then *Actions* (or ⋮) in the upper-right corner, and *Copy user ID*.

[source,yaml]
----
spec:
  assignees:
    - 1234567
  reviewers:
    - 7654321
----

=== Labels

`labels` are applied to the merge request, and *GitLab creates any label that does not exist yet* as a new project label. This is the opposite of the GitHub plugin, where a missing label is an error.

=== Merge behavior

`automerge: true` turns on GitLab's auto-merge, so the merge request merges by itself once its conditions are met - pipeline succeeded, required approvals given. It is a single boolean: there is no equivalent of the GitHub plugin's `merge.strategy`, and Updatecli never merges client-side here.

The following options shape what merging produces, and the project's own settings may override them:

`squash`:: Squashes the commits of the source branch into one on merge.
`removesourcebranch`:: Deletes the working branch once merged.
`mergecommitmessage`, `squashcommitmessage`:: Override the commit messages GitLab generates. Left empty, the project's message templates apply.
`allowcollaboration`:: Lets members who can merge the target branch push to the merge request's source branch.

=== Cleanup

Cleanup is *not implemented* for this plugin. `updatecli apply --clean-git-branches` removes working branches that ended up with no changes, but a merge request already opened for one of them is not closed automatically (that stays a manual step).

The same goes for the options this plugin does not expose. If closing stale merge requests, or anything else missing here, is something you would use, say so on link:https://github.com/updatecli/updatecli/issues[the Updatecli issue tracker] (these gaps are unimplemented rather than deliberate, and interest is what gets them prioritised).

== Example

[source,yaml]
----
# updatecli.yaml
{{<include "assets/code_example/docs/plugins/actions/gitlab_mergerequest/updatecli.yaml">}}
----

== Links

* link:https://docs.gitlab.com/ee/user/project/merge_requests/[Documentation: GitLab merge requests]
* link:https://docs.gitlab.com/ee/user/project/merge_requests/auto_merge.html[Documentation: GitLab auto-merge]
