I am trying to get the git short hash in a variable. I tried to set GIT_COMMIT_SHORT variable to run 'git rev-parse --short HEAD' but it didn't work. I need this variable to pass to ant build script so the package name include this short hash.
I am running Jenkins on windows 2008 server.
Thanks
The short hash is just a shorter version of the original (long) hash. The original Git hash is 40 bytes long while short is only 8 bytes long. However, it becomes difficult to manage it (in terms of using typing or displaying), and that's why the short version is used.
The git plugin provides fundamental git operations for Jenkins projects. It can poll, fetch, checkout, branch, list, merge, tag, and push repositories.
Probably the simplest way to achieve the result you want would be to use the GIT_REVISION token makro, like this:
${GIT_REVISION,length=6}
Have a look at https://wiki.jenkins-ci.org/display/JENKINS/Token+Macro+Plugin for more details.
Hope this helps,
Jan
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With