2016-06-28 130 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