I am using Jenkins Pipeline for my .net project. I dont want to use the default build number so I am trying to set the build number using the following commands in groovy.
def short_hash = bat(script: 'git log --pretty=format:\'%%h\' -n 1', returnStdout: true)
currentBuild.displayName = '0.0.' + "${env.BUILD_NUMBER}" +'.' + short_hash
What I am observing is that short_hash is having the value of batch command along with the result.
The jenkins documentation here states that "script Executes a Batch script. Multiple lines allowed. When using the returnStdout flag, you probably wish to prefix this with @, lest the command itself be included in the output."
I tried using @ but it is giving error while executing it. Any pointers?
@
char? Which error is coming up? – Armet@
is acmd
prefix for "don't echo the command line" and the command isgit
, it should be:... script: '@git ...
– Disconsider