Alex Rivera | Logout

how to get git short hash in to a variable in Jenkins running on windows 2008

Asked 2013-06-05T15:17:57.690
33

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

Edit
Report

1 Answer

1

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 2013-06-05T15:24:57.787

Your Answer