CI/CD pipeline - get list of changed files

FInally found a solution starting from @mpp’s idea, and an answer in this thread:

  1. If this is a private repository, you will need to add a new ssh key in the CI.

  2. Fetch the branch you want to merge:
    git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME

  3. Compare the current commit with the branch you want to merge with:
    git diff --name-only $CI_COMMIT_SHA $CI_MERGE_REQUEST_TARGET_BRANCH_NAME

Voilà !

3 Likes