I would like to add label "foo" once merge request is created.
How can I do it?
If not possible via gitlab gui (using some robot) it is possible via gitlab api?
I would like to add label "foo" once merge request is created.
How can I do it?
If not possible via gitlab gui (using some robot) it is possible via gitlab api?
It is possible to do so using Gitlab quick actions in the merge requests' default description.
In Gitlab
on the project level go to:
Settings -> Merge requests -> Default description template for merge requests
and set the following description:
/label ~123 ~"my-label"
where 123
- is the id of one existed label and my-label
is the name of another existed label. If labels do not exist - it will not work.
You’d have to register a new Webhook, then have something listen and check for the Merge Request Event (https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#merge-request-events).
Then you’ll have to parse it, checking the
object_attributes.state
field to see if the MR was created, updated, merged, closed, or pushed to, and grab the ID inobject_attributes.id
., Then you can use the Merge Request API to add a label to the MR. You’ll have to use the Update MR operation and change the labels (https://docs.gitlab.com/ee/api/merge_requests.html#update-mr)