I have two branches, one is master
, the other is feat/test
. For some reason, I have to get all changed files in multiple commits of a merge request in gitlab-ci.yml. So I wrote the script like this:
variables:
GIT_STRATEGY: clone
GIT_DEPTH: 0
script:
- echo $CI_COMMIT_REF_NAME
- echo $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
- export CHANGED_FILES="`git diff --no-commit-id --name-only -r origin/${CI_COMMIT_REF_NAME} ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}`"
- echo "All changed files are below"
- echo "${CHANGED_FILES}"
The CI_COMMIT_REF_NAME
can be logged, which is master
. However, I couldn’t get the CHANGED_FILES
or CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
. They just logged nothing. So is there any way to get all commited changed files in gitlab-ci.yml? I have checked many solutions in the gitlab forum but none of them worked for me.