NicoESIEA
NicoESIEA

Reputation: 539

How can I know the updated file during the gitlabci pipeline

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)

Upvotes: 0

Views: 637

Answers (1)

djuarezg
djuarezg

Reputation: 2541

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

Upvotes: 1

Related Questions