I am trying to set up builds on Jenkins. When the build is successful, I push a tag of the build using the Post build Action Git Publisher.
Until Now, these have been done manually, with the tag being given the version number, A.B.C.D (which comes from a text file). Now we are using Jenkins, D comes from the $BUILD_NUMBER Jenkins variable, but A.B.C are stored in a text file within the workspace. Is there a way I can pass A.B.C to the git publisher? or will have to do all of the git commands in a script?
Using Jenkins v1.624. Updating not currently possible (before people suggest this)
Not entirely sure if this will work the Post build Action Git Publisher (as I don't use it), and I can only test this on:
Jenkins ver. 2.32.3
EnvInject+Plugin 1.93.1
Groovy+plugin 1.30
Based on suggestion by 'Joerg S' in this post:
Creating a Jenkins environment variable using Groovy
Add a 'Execute Groovy Script' build step to read in the workspace file (
tmpFile
) containing A.B.C and convert it to a java based properties file -name:value
) :Then add a 'Inject Environment Variables' build step to read in the new file, so
Properties File Path
isproperties.text
You should then be able to use the
${CUSTOM_TAG}
in your post build git publish as the TAG, as now it's an environment variable.If this doesn't work check out the groovy code in the link above, it might offer something else.