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
I'm not entirely sure I follow your question, but two things to consider:
git diff --stat {X SHA-1 ID} should work for what you're looking for. Or, you could be more explicit and do git diff --stat {X SHA-1 ID} {X SHA-1 ID + 3 commits} which will give you the files changes between the two commits given. This will output something like:
Library/ENV/4.3/cc | 3 ++-
Library/Formula/cmu-sphinxbase.rb | 10 +++++++---
Library/Formula/fb-client.rb | 11 +++++++++++
I leave it as an exercise for the reader to parse that output into just a list of files.
You should probably be doing a full, clean build in Jenkins, and not only building certain files. You may end up getting caught by weird incompatibilities between built files. But that's beyond the scope of this question.
To break this problem down into parts:
$CUR_HASH) and commit when Jenkins last built (Last Build Revision, which we will call $LAST_HASH). It sounds like you already have these, and if not, that's sort of beyond the scope of the question.$LAST_HASH and $CUR_HASH - This is the aforementioned git diff --stat $LAST_HASH $CUR_HASH command, which will print out something like the above.Get just the filenames from the output - doing this in bash, you could pipe the output of git diff to grep '\|' to get just the lines with filenames, and then pipe it to awk '{print $1} to get just the filename, without the stats. So the command is now something like:
git diff --stat $LAST_HASH $CUR_HASH | grep '\|' | awk '{print $1}'
Create tarball from just the files changed - you can send the output of the above to tar like so:
tar cvzf /tmp/build.tar.gz `git diff --stat $LAST_HASH $CUR_HASH | grep '\|' | awk '{print $1}'`
I think that covers everything that you're trying to do. Obviously, these commands can't just be copy/pasted since I don't know everything about your environment, but it's a good start.