Skip to content

Instantly share code, notes, and snippets.

@joshjohanning
Created March 30, 2023 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshjohanning/2537ebe8dad6875a9c33b4f24b35b2e7 to your computer and use it in GitHub Desktop.
Save joshjohanning/2537ebe8dad6875a9c33b4f24b35b2e7 to your computer and use it in GitHub Desktop.
create gitlab merge requests via the api
#!/bin/bash
GITLAB_URL="https://example.gitlab.com/"
PROJECT_ID="2" # get this id via the repo/project's overview page
ACCESS_TOKEN="glpat-abc"
# Create a new merge request
curl --header "Private-Token: $ACCESS_TOKEN" \
"$GITLAB_URL/api/v4/projects/$PROJECT_ID/merge_requests" \
--data "source_branch=my-branch" \
--data "target_branch=main" \
--data "title=My new merge request" #--data "description=this is a description"
# description will be `null` - which is what I was testing
# see also: https://docs.gitlab.com/ee/api/merge_requests.html#create-mr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment