What's the best (or any!) way to put the output of a command in a Jenkins build name?
I'd like to put the output of the git describe
command into the build name of a Jenkins job.
I've installed the build-name-setter
plugin with the hopes of setting the build name to something like:
${ENV, var="GIT_DESCRIBE"}
I just don't know how to set $GIT_DESCRIBE
before the name is set! I've tried using the EnvInject
plugin. The only way to dynamically set the environment variables is to use groovy script. This would work well, except my job is running on a remote slave and the groovy script is (apparently) running only on the master.
If you need the "describe" data (i.e. you can't just use the existing $GIT_BRANCH
or $GIT_COMMIT
environment variables), you could add an "Execute shell step" with:
echo GIT_DESCRIBE=$(git describe) > git.properties
Then after that, add an EnvInject build step which injects properties from the git.properties
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With