1
votes

I'm trying to create custom build format in Jenkins. My build ideally would have the ${GIT_TAG}.${BUILD_NUMBER}

I've installed the buildnamesetter plugin, https://wiki.jenkins-ci.org/display/JENKINS/Build+Name+Setter+Plugin.

However I can't figure out how can I access the build parameters, there is a way to access the environment parameters but not the build ones.

Eventually all I get with ${GIT_TAG}.${BUILD_NUMBER} is the running number of the build such as: #24 and error in the execution log:

Unrecognized macro 'GIT_TAG' in '${GIT_TAG}.${BUILD_NUMBER}'

I might be looking in the wrong direction and different plugin can be used, any help will be appreciated.

Jenkins config of the plugin

I'm still stuck since I have a requirement to have additional parameter as in the build number string and this one is selected by the user from Choice Parameter and Choice Parameter can't be converted to be environment AFAIK. Any ideas would be very appreciated.

1
I don't have a Jenkins CI with me atm, and I can't tell you exactly where to look for it. There is a link somewhere on the CI interface that lists all available build parameters. That page also shows you how to reference them in your customs build name.vincentleest
In the plugin doc they are saying that you can access the ENV parameters by ${ENV,var="VARIABLENAME"}, however my parameter ${GIT_TAG} is not ENV but build runtime parameter that specified by the user.Dmitry R
Ok, found a workaround, not sure if it's elegant, and answers all my needs but: 1. Installed the plugin global-variable-string-parameter 2. Changed my GIT_TAG parameter to be global-variable-string-parameter instead of string-parameter 3. Used my custom env parameter ${ENV,var="GIT_TAG"}.${BUILD_NUMBER} for the Set Build Name plugin.Dmitry R

1 Answers

1
votes

Ok, finally after struggling for few hours seems that solution was found I'll post it here in case it might help to someone else:

  • Need the following plugins:
    1. build-name-setter
  • Create your run time parameter that set by the user
  • Use the following built in Jenkins functionality to prepare the environment before the run:

enter image description here

  • Set the Properties Content to have any parameter that your user/script supplies and you would like it to be ENV parameter

How I used it:

enter image description here

  • When referring the env parameter in the build-name-setter plugin use the following example as reference on how to access the environment parameters ${ENV,var="SELECTED_DEVICE"}

How I used it:

enter image description here