Last active
June 20, 2019 05:39
-
-
Save styx/9387062 to your computer and use it in GitHub Desktop.
Create Gitlab pull request from command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BROWSER='google-chrome' | |
#GITLAB_SECRET='' | |
ENDPOINT='http://gitlab.activeby.net/api/v3' | |
PROJECT='activebilling/core' | |
#curl --header "PRIVATE-TOKEN: xxx" "http://gitlab.activeby.net/api/v3/projects/activebilling%2Fcore" | awk '{match($1,"[0-9]+",a)}END{print a[0]}' | |
PROJECT_ID=177 | |
ACTION="projects/$PROJECT_ID/merge_requests" | |
CURRENT_BRANCH=`git branch | grep '^\*' | awk '{ print $2; }'` | |
git push --set-upstream origin $CURRENT_BRANCH || (echo "Failed to push\n" && exit 1) | |
MERGE_REQUEST_ID=$(curl -s --header "PRIVATE-TOKEN: $GITLAB_SECRET" --data "source_branch=$CURRENT_BRANCH&title=$CURRENT_BRANCH&target_branch=master" "$ENDPOINT/$ACTION" | grep -o '"iid":[0-9]\+' | grep -o '[0-9]\+') | |
$($BROWSER "http://gitlab.activeby.net/$PROJECT/merge_requests/$MERGE_REQUEST_ID") 2>/dev/null | |
echo "http://gitlab.activeby.net/$PROJECT/merge_requests/$MERGE_REQUEST_ID/diffs" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how did you generate the gitlab_secret, is this your own gitlab server?