问题
During the gitlab pipeline (triggered after each commit on my branch), I want to know which files are concerned by the commit in order to apply specific bash script regarding each file.
I'm currently using the following code in my gitlabci.yaml
file:
- export DIFF=$(git show --stat HEAD)
- ./myBashScript.sh
Then I'm using $DIFF
in my bash script.
But is there a better approach? (I'm using a local gitlab 10.8)
回答1:
You can use already existing CI variables to do something like this to retrieve the list of changed files:
git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA
CI_BUILD_BEFORE_SHA and CI_BUILD_REF if you are running on Gitlab 8.x
来源:https://stackoverflow.com/questions/55514613/how-can-i-know-the-updated-file-during-the-gitlabci-pipeline