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.

  • Prevent git committers from creating certain directories
  • Does NPM ignore files listed in .gitignore?
  • Is it safe to commit, branch and amend at original branch?
  • Git connect using ssh on windows
  • How to make eclipse remember ssh key passphrase?
  • JIRA smart commit - Block git commit without JIRA ticket number
  • 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.

  • heroku rollback didn't update the HEAD remote branch, did it?
  • Atlassian Stash vs Git Client
  • Using Xcode4 git integration with git-flow
  • How do you merge in GIT on Windows?
  • git server with eclipse project
  • How to add an already existing branch in an already existing Android Repository on Eclipse
  • 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 “origin/foo
    • 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.

    Git Baby is a git and github fan, let's start git clone.