how to find out list of all changed files in git for full jenkins build and not for a particular commit?

前端 未结 5 1675
梦毁少年i
梦毁少年i 2020-12-05 19:57

How to find all changed files since last commited build in GIT ? I want to build not only the changed files at head revision but also, all the changed files which got chang

5条回答
  •  甜味超标
    2020-12-05 20:37

    According to https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-Environmentvariables, Jenkins provides the environment variables:

    • GIT_COMMIT - SHA of the current
    • GIT_PREVIOUS_COMMIT - SHA of the previous built commit from the same branch (the current SHA on first build in branch)

    I plan to leverage those to accomplish something similar.

    So what you'll want is something like:

    tar cvzf /tmp/build.tar.gz `git diff --stat $GIT_PREVIOUS_COMMIT $GIT_COMMIT | grep '\|' | awk '{print $1}'`
    

提交回复
热议问题