Issue
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
Solution
I suggest you use the EnvInject plugin to load the parameter from a properties file you create that holds the hash.
Echo the result of your git
command to a formed key=value
file in your job's workspace and load it with the plugin I mentioned.
I used it for such needs and it's very simple.
I hope this helps.
EDIT: How to write a properties file in windows:
@for /f "delims=" %l in ('git command') do @echo hash=%l >> hash.properties
Then, you can load hash.properties
with the plugin.
Answered By - Eldad Assis