GIt – Copying the files that has been modified on a branch part of jenkins job
As part of my build job, I want to copy the files that has been modified in the current build since the last build.
And have those files as a output. I can compare the last built commit and the current revision and copy files, but how do I access the last built commit.
Also, if there is any way Git pull is not executed when I execute my build job and I can check for the Last Revision and store it in the variable and then once Pull is executed, I can get the New revision and compare both to get the files copied over.
One Solution collect form web for “GIt – Copying the files that has been modified on a branch part of jenkins job”
As mentioned in “How to find out list of all changed files in git for full jenkins build and not for a particular commit?”, and detailed in “Advanced Features” section of the Git Plugin for Jenkins documentation:
The git plugin sets several environment variables you can use in your scripts:
GIT_COMMIT– SHA of the current
GIT_BRANCH– Name of the branch currently being used, e.g. “
master” or “
GIT_PREVIOUS_COMMIT– SHA of the previous built commit from the same branch (the current SHA on first build in branch)
So you can take advantage of those to do your diff and copy the right files.