stepsSub-command "@echo off |" is there to eliminate repetition of command to system output console, so we see only command result.
{
script
{
env.GitCurrentHash=bat(returnStdout: true, script: "@echo off | git --git-dir=${WORKSPACE}\\.git rev-parse origin/${branch}").trim()
}
echo "Current Git Hash: ${GitCurrentHash}"
echo "Current Git Hash: ${GIT_COMMIT}"
}
If you want to collect git hash from file level use construction:
env.gitcurrent=bat(returnStdout: true, script: "@echo off | git --git-dir=${WORKSPACE}\\.git rev-parse HEAD 2> nul || echo githash").trim()
If you want to know branch name from file level use construction:
env.gitbranch=bat(returnStdout: true, script: "@echo off | git --git-dir=${WORKSPACE}\\.git name-rev --name-only HEAD 2> nul || echo gitbranch").trim()
That's all...
Žádné komentáře :
Okomentovat
Dotaz, připomínka, oprava?
(pokud máte problém s vložením příspěvku, vyzkoušejte to v prohlížeči Chrome)