Search code examples
gitjenkinsgroovy

How not to lose git commit file changes with Jenkins built in checkout


Im trying to map the diferent files that were last modified during the commit, with the command:

git diff --name-only --submodule=diff HEAD

But it results in only returning modified files during the piepeline process... Inside the checkout phase of Jenkins I see the following checkout line:

git checkout -f <my commit hash> # timeout=10

By searching on the internet it seems that -f option will delete all history of changes and create a new hash commit. I don't wan't this to happen, so I could grab the files that were changed.

Any ideas would be very welcome.


Solution

  • Are you looking for this?

    git diff --name-only HEAD^!