Skip to content

Instantly share code, notes, and snippets.

@Voronenko
Created October 19, 2022 11:20
Show Gist options
  • Save Voronenko/e7a25a6a83c9260ce48b614b1bae1227 to your computer and use it in GitHub Desktop.
Save Voronenko/e7a25a6a83c9260ce48b614b1bae1227 to your computer and use it in GitHub Desktop.
Gitlab getting merged branch name
- 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