1
votes

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?

1
Do you want to label the MR or the issue?meliade
I would like to label MR.nirebam368

1 Answers

1
votes

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 in object_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)