2016-06-28 110 views
1

我有2个属性文件,我希望通过邮件发送其内容。我要做的就是这样:覆盖在Jenkins本地创建的环境变量

  1. 阅读与EnvInject

enter image description here

这些文件
  • 使用这些可变因素为使通过邮件发送: enter image description here
  • 这些配置文件包含不同的链接和日期,我在电子邮件中看到相同的输出:

    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 
    

    即使我尝试“取消设置”命令,将$ {Link}设置为非oereriden时,它表示意思。

    [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 
    

    您能否帮我解决这个问题,或者让我煽动你呢?

    +0

    您不能取消设置系统环境变量。您只能删除继承的环境变量。 – CSchulz

    +0

    请你详细说明一下吗?我对此比较陌生......我正在设置系统环境变量?什么是继承的环境变量? – Dim

    回答

    2

    发生这种情况的原因在于env-inject插件的工作方式。如果在一次调用中同时使用“属性文件路径”“属性内容”字段,则它们不会被顺序处理,而是被并行处理。因此,当您设置$LinkPL时,$Link的值仍然较旧。解决方案是让进行两个env注入步骤,一个注入道具文件,另一个注入步骤以利用结果。

    实施例:

    enter image description here

    输出:

    enter image description here

    此外,您不能取消设置一个变量的在壳中的值的步骤要尝试做的方式。取消设置只会影响该步骤。

    +0

    哇!谢谢你......你救了我。 – Dim