Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

jenkins

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

like image 769
user2367078 Avatar asked Jun 05 '13 15:06

user2367078


People also ask

What is git short hash?

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.

Does Jenkins poll commit git?

The git plugin provides fundamental git operations for Jenkins projects. It can poll, fetch, checkout, branch, list, merge, tag, and push repositories.


1 Answers

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

like image 111
Jan Molak Avatar answered Sep 22 '22 03:09

Jan Molak