I need to create a merge request from a forked GitLab repository into the original repository, while running a bash script.
Asked
Active
Viewed 5,664 times
1 Answers
4
Use the API
An example merge request would look like this:
curl --header "PRIVATE-TOKEN: " -X POST https://gitlab.example.com/api/v3/projects/project_id/merge_requests/?target_project_id=id_of_parent_project

jaxxstorm
- 12,422
- 5
- 57
- 67
-
Thank you. The GitLab API documentation (https://docs.gitlab.com/ee/api/merge_requests.html) says: **POST /projects/:id/merge_requests** Could you please explain how I am supposed to come from this to what you wrote? I am asking since I need to understand the syntax for my particular URL. – Alex K Dec 19 '16 at 22:31
-
What exactly is unclear – jaxxstorm Dec 20 '16 at 07:21
-
It said: "projects/:id", you said: "project_id". Also, where did you get this variable name: **target_project_id**? – Alex K Dec 20 '16 at 15:36
-
The project id can be grabbed from the API too, using the projects endpoint. The variable `target_project_name` is an attribute in the API docs listed above. – jaxxstorm Dec 20 '16 at 16:00
-
1Yes, thank you, I got it: it is something like: curl --header "PRIVATE-TOKEN: XXXXXX" -X POST "https://gitlab.example.com/api/v3/projects/ 12345merge_requests?source_branch=XXXXXX& target_branch=XXXXXX&title=Test&target_project_id=12356" Sorry about multiple attempts to format properly. – Alex K Dec 20 '16 at 18:34