Jenkins inject environment variable

后端 未结 2 1064
不思量自难忘°
不思量自难忘° 2020-12-11 05:35

In a Jenkins job I\'m doing a couple of actions that reside in the pre-step build, such as executing a shell script. With the use of the Jenkins plugin \"EnvInject\" I want

2条回答
  •  难免孤独
    2020-12-11 05:51

    I had a similar requirement in my project, except my project was Maven. To use a variable value from jenkins to my java code, I used -DargLine="-DEnv=$Environment" inside "Build->Advanced->JVM Options". From my java code, I fetched the value of "Env" using System.getProperty(). FYI "Environment" is my Jenkins Variable, and "Env" is variable which is storing the value passed from jenkins into its variable(Environment) and fetched in java code using System.getProperty().

提交回复
热议问题