I need to create a merge request from a forked GitLab repository into the original repository, while running a bash script.
1 Answer
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
5 Comments
Alex K
Thank you. The GitLab API documentation (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.
jaxxstorm
What exactly is unclear
Alex K
It said: "projects/:id", you said: "project_id". Also, where did you get this variable name: target_project_id?
jaxxstorm
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.Alex K
Yes, thank you, I got it: it is something like: curl --header "PRIVATE-TOKEN: XXXXXX" -X POST "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.