Created
October 19, 2022 11:20
-
-
Save Voronenko/e7a25a6a83c9260ce48b614b1bae1227 to your computer and use it in GitHub Desktop.
Gitlab getting merged branch name
This file contains hidden or 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
- MR_BRANCH_LAST_COMMIT_SHA=$( | |
curl -s \ | |
--header "PRIVATE-TOKEN: $CI_PRIVATE_TOKEN" \ | |
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/commits/$CI_COMMIT_SHA" |\ | |
jq -r '.parent_ids | del(.[] | select(. == "'$CI_COMMIT_BEFORE_SHA'")) | .[-1]' | |
) | |
- MR_BRANCH_NAME=$( | |
curl -s \ | |
--header "PRIVATE-TOKEN: $CI_PRIVATE_TOKEN" \ | |
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/commits/$MR_BRANCH_LAST_COMMIT_SHA/merge_requests" |\ | |
jq -r '.[0].source_branch' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment