Jenkins inject environment variable

后端 未结 2 1061
不思量自难忘°
不思量自难忘° 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 06:12

    My solution:

    Create a "Build a free-style software project".

    1. Jenkins > New Item > Build a free-style software project
    2. Add 1st step: Execute shell @ Build, and echo key=value pairs to a .properties file
    3. Add 2nd step: Inject environment variables, use the .properties file as defined in step 2
    4. Add 3rd step: Invoke top-level Maven targets

    All custom environment variables are accessible with the key as defined in step #2. This was the only way I found to inject environment variables from shell to java.

    As explained.

提交回复
热议问题