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.
Setting Stage Level Environment Variable It is by using the env variable directly in the script block. We can define, let us say, USER_GROUP and display it. You will see that the underlying shell also has access to this environment variable. You can also set an environment variable using withEnv block.
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
.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