I'm trying to create environment variable via internal Maven plugin so I can access it via Jenkins pipeline.
Normally - inside the JVM I can run: System.setProperty("myvar","myvalue");
but of course it can be accessed via the Java itself only. Running echo ${myvar}
from the pipeline script will return null.
I am looking for a way to add environment variable to Jenkins build maybe via Jenkins API. is it possible? Are there better ways to do it?
We are working on TeamCity and it can be easily done via ##teamcity[setParameter name='envname' value='envvalue']
. Any ideas how to do it from Jenkins?
Asked
Active
Viewed 50 times
1

Nir Koren
- 241
- 4
- 11
-
https://stackoverflow.com/questions/10789341/how-to-set-an-environment-variable-programmatically-in-jenkins-hudson – rohit thomas Jun 11 '18 at 05:27
-
Thanks but I'm still looking for Java example or REST call example – Nir Koren Jun 11 '18 at 10:58