After merge there is a new commit with new SHA in gitlab.
In CI/CD variables there is a CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
variable. Also there are a few ways to know some other commit data in command line like git rev-parse --verify HEAD
and etc.
So, how to get source commit SHA for special merge commit?
To understand the question clearly I'll try to describe the case.
branches: master, dev
commits: dev_1, dev_2, dev_3, merge_to_master_dev_123, dev_4, dev_5, dev_6, merge_to_master_dev_456
When I run (or rerun) the pipeline for merge_to_master_dev_123 I need to get dev_3 commit SHA.
When I run (or rerun) the pipeline for merge_to_master_dev_456 I need to get dev_6 commit SHA.
I'm going to use it in GitLab Runner in gitlab-ci.yml scripts (shell scripts especially).
And get latest request of source branch is not what I'm looking for, because I can rerun merge_to_master_dev_123 pipeline after merge_to_master_dev_456, merge_to_master_dev_... pipelines.
So how to do it?