Reading all commits in merge request

Hello! Sorry for my English)
Please tell me how can I extract all the commits from the merge request in order to see in the future what files changed in these commits?
Is this even possible?
At the moment my script in gitlab-ci.yml only reads the last commit after mr to the master branch!

Hi,

you can use something like this

job1:
  variables:
    GIT_DEPTH: 0
  script:
    - git fetch origin ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}
    - git diff --name-only origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}...

How can I correctly add everything to this script?

stages:
  - deploy

.deploy_script: &deploy_script |
  token=$(curl -s -X POST --data '{"role_id":"'"$WRITE_TO_VAULT_ROLE_ID"'","secret_id":"'"$WRITE_TO_VAULT_SECRET_ID"'"}' https://myapp.ru/v1/auth/approle/login | jq -r .auth.client_token)
  echo "$token"
  files=($(git diff-tree --no-commit-id --name-only -r $CI_COMMIT_SHA)) # make array from files splited by newline
  for file in "${files[@]}"
  do
  cifile="gitlab-ci.yml"
  if [[ "$file" != "$cifile" ]];
  then
  layer=$(echo "$file" | grep -oP "\-\K\w+(?=\.)")
  app_name=$(echo "$file" | grep -oP "(\w+).*(?=-\w+)")
  echo "convert file $file"
  java -Dfile.encoding=UTF8 -jar yaml-to-json-converter-1.0.0.jar $file config.json
  cat config.json
  curl -s -X POST "${VAULT_URL}/v1/secret/gitlab-ci/app/config/$app_name/$layer" -H "Content-Type: application/json" -H "X-Vault-Token: $token" --data-raw "$(cat config.json)";
  fi
  done
  rm config.json
  token="";

deploy_to_vault:
  image: harbor.myapp.ru/s-devops/app-pa-jq:1.0.1
  stage: deploy
  script:
    - *deploy_script
  only:
    - master

.auto_devops: &auto_devops |
  TRACE=1
  [[ "$TRACE" ]] && set -x

  function example() {
    echo ""
  }

before_script:
  - *auto_devops

it would go after echo "$token" replacing the files=... like this

.deploy_script: &deploy_script |
  token=$(curl -s -X POST --data '{"role_id":"'"$WRITE_TO_VAULT_ROLE_ID"'","secret_id":"'"$WRITE_TO_VAULT_SECRET_ID"'"}' https://myapp.ru/v1/auth/approle/login | jq -r .auth.client_token)
  echo "$token"
  git fetch origin ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}
  files=($(git diff --name-only origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}...)) # make array from files splited by newline
  for file in "${files[@]}"
  do
  cifile="gitlab-ci.yml"
  if [[ "$file" != "$cifile" ]];
  then
  layer=$(echo "$file" | grep -oP "\-\K\w+(?=\.)")
  app_name=$(echo "$file" | grep -oP "(\w+).*(?=-\w+)")
  echo "convert file $file"
  java -Dfile.encoding=UTF8 -jar yaml-to-json-converter-1.0.0.jar $file config.json
  cat config.json
  curl -s -X POST "${VAULT_URL}/v1/secret/gitlab-ci/app/config/$app_name/$layer" -H "Content-Type: application/json" -H "X-Vault-Token: $token" --data-raw "$(cat config.json)";
  fi
  done
  rm config.json
  token="";

Thank you my freind)

It my solution:

git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
files=($(git diff-tree --no-commit-id --name-only -r $CI_COMMIT_BEFORE_SHA -r $CI_COMMIT_SHA))