问题
I have 2 properties files that I wish send their content via mail. What I do is so:
- Read those files with EnvInject
- Use those varibles as so to send the via mail:
Those config files are containing different link and date I see in email the same output:
Android Mobile Client Release Notes CH
Link: ftp://testlink_CH
Date: 28/06/2016
Android Mobile Client Release Notes PL
Link: ftp://testlink_CH
Date: 28/06/2016
Whitch meanns when ${Link} is set its not oveeriden even if I try "unset" command.
[EnvInject] - Injecting environment variables from a build step.
[EnvInject] - Injecting as environment variables the properties file path 'AndroidDev/CH/config.properties'
[EnvInject] - Variables injected successfully.
[EnvInject] - Injecting as environment variables the properties content
LINK_CH=${Link}
DATE_CH=${Date}
[EnvInject] - Variables injected successfully.
[mvandroid] $ /bin/sh -xe /tmp/hudson108948632979693109.sh
+ unset Link
+ unset Date
[EnvInject] - Injecting environment variables from a build step.
[EnvInject] - Injecting as environment variables the properties file path 'AndroidDev/PL/config.properties'
[EnvInject] - Variables injected successfully.
[EnvInject] - Injecting as environment variables the properties content
LINK_PL=ftp://testlink_CH
DATE_PL=28/06/2016
Can you please help me with this or give me you incite on this?
回答1:
The reason this is happening lies in the way the env-inject plugin works. If you use both "Properties File Path" and "Properties Content" fields in one invocation, they are not processed sequentially but are instead handled in parallel. Therefore, when you are setting $LinkPL
, the value of $Link
is still old. The solution is to make two env-inject steps, one to inject the props file and the next to make use of the results.
Example:
Output:
Additionally, you cannot unset a value of a variable in a shell step the way you are attempting to do it. Unsetting it will only affect that shell step.
来源:https://stackoverflow.com/questions/38077165/override-environment-variable-created-locally-in-jenkins