How can I know the updated file during the gitlabci pipeline

梦想与她 提交于 2019-12-08 10:36:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!