Reputation: 11289
I have a jenkins build process and i use a python script to calculate the new version:
import string import os print 'Current version is ' + os.environ['POM_VERSION'] versionArr = string.split(os.environ['POM_VERSION'], '.') versionArr[2] = str(int(versionArr[2]) + 1) if int(versionArr[2]) > 100: versionArr[2] = '0' versionArr[1] = str(int(versionArr[1]) + 1) if int(versionArr[1]) > 100: versionArr[0] = str(int(versionArr[0]) + 1) versionArr[1] = '0' print versionArr print 'New version will be: ' + versionArr[0] + '.' + versionArr[1] + '.' + versionArr[2] os.environ['NEW_POM_VERSION'] = versionArr[0] + '.' + versionArr[1] + '.' + versionArr[2]
And then i want to run
versions:set -DnewVersion=${NEW_POM_VERSION} -DgenerateBackupPoms=false
on a different step. but the ${NEW_POM_VERSION}
stays the same and does not translate to the value i set.
Am i trying to call the variable in the wrong way. i also tried using $NEW_POM_VERSION
which didn't work as well
so how am i supposed to export the variable correctly to my environment.
Thanks.
Upvotes: 6
Views: 12213
Reputation: 27485
Jenkins spawns a new environment for each build step (and post-build step). Setting a value in one will not be persisted to the rest.
You need EnvInject plugin.
param=value
.Upvotes: 5