- 1 year ago
How to get commitHash from windows slave
Comment
1 / 1
To get the commit hash from a Windows slave using Git, you can use the following command in a Windows batch script:
batch@echo off
for /f "usebackq" %%H in (`git rev-parse HEAD`) do set commitHash=%%H
echo %commitHash%
Here's a breakdown of what the script does:
The
git rev-parse HEAD
command retrieves the commit hash of the current HEAD revision.The
for
loop captures the output of the command and assigns it to thecommitHash
variable.Finally, the
echo
command prints the commit hash to the console.
Save the script with a .bat
extension and run it on your Windows slave machine. It will display the commit hash of the current HEAD revision.
Make sure that you have Git installed and the necessary environment variables properly set up on the Windows slave machine for the script to work correctly.