覆盖在詹金斯本地创建的环境变量 [英] Override environment variable created locally in Jenkins

查看:34
本文介绍了覆盖在詹金斯本地创建的环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个属性文件,希望通过邮件发送它们的内容.我是这样做的:

  1. 使用

    1. 使用这些变量通过邮件发送通行证:

    这些配置文件包含不同的链接和日期,我在电子邮件中看到的是相同的输出:

      Android移动客户端发行说明CH链接:ftp://testlink_CH日期:28/06/2016Android移动客户端发行说明PL链接:ftp://testlink_CH日期:28/06/2016 

    即使我尝试"unset"命令,当$ {Link}设置为非时,Whitch的意思是.

      [EnvInject]-从构建步骤中注入环境变量.[EnvInject]-将属性文件路径"AndroidDev/CH/config.properties"作为环境变量注入[EnvInject]-变量成功注入.[EnvInject]-将属性内容作为环境变量注入LINK_CH = $ {Link}DATE_CH = $ {日期}[EnvInject]-变量成功注入.[mvandroid] $/bin/sh -xe/tmp/hudson108948632979693109109.sh+未设定连结+未设定日期[EnvInject]-从构建步骤中注入环境变量.[EnvInject]-将属性文件路径"AndroidDev/PL/config.properties"作为环境变量进行注入[EnvInject]-变量成功注入.[EnvInject]-将属性内容作为环境变量注入LINK_PL = ftp://testlink_CHDATE_PL = 28/06/2016 

    您能帮我这个忙还是请您对此煽动?

    解决方案

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

    示例:

    输出:

    此外,您在外壳步骤中无法尝试设置变量的值无法设置.取消设置只会影响该shell步骤.

    I have 2 properties files that I wish send their content via mail. What I do is so:

    1. Read those files with EnvInject

    1. 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?

    解决方案

    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.

    这篇关于覆盖在詹金斯本地创建的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆