During the first build, I am running the following:
result.each { key, val ->
env.setProperty(key,val)
}
Where result contains a set of key value pairs I want to set. If I do this I can see those variables on the environment in that build.
In my next build, I am running the following:
def staticNumber = 22
def job = Jenkins.instance.getItemByFullName('my-job-name')
def builds = job.builds
def buildByNum = builds.find { it.number == staticNumber }
echo "${buildByNum.getEnvironment(buildByNum.getListener())}"
echo "${buildByNum.getEnvVars()}"
Even though the environment was updated on the previous build, when I read it from the new build it is missing the new properties. I have read multiple SO articles about how getEnvVars() is very limited.
Is there a way to have the key/value pairs from 'result' be available to the new build? It doesn't have to be through env, I just figured that would be the most simple.