简体   繁体   English

从文件设置Jenkins全局环境变量

[英]Set Jenkins global environment variables from a file

Basically, I am running several jobs on Jenkins which have 2 different sets of email distribution lists, one for production, the other is for when we do the dry run. 基本上,我在Jenkins上运行多个作业,这些作业有两组不同的电子邮件分发列表,一组用于生产,另一组用于我们进行空运行时。 I want to be able to easily switch between the two. 我希望能够轻松地在两者之间切换。 Currently, we have these as environment variables in the global properties section under 'Manage Jenkins' 目前,我们在“管理詹金斯”下的“全局属性”部分中将这些作为环境变量使用

在此处输入图片说明

The problem is that I have to change these between the dry run and production run (there is a email distro for each app). 问题是我必须在试运行和生产运行之间进行更改(每个应用都有一个电子邮件发行版)。 I want to put these into a properties file so I can easily switch. 我想将它们放入属性文件,以便可以轻松切换。 I thought I could do this, but it didn't work: 我以为我可以这样做,但是没有用:

在此处输入图片说明

I did a quick test on my Linux environment and it works well with the Envfile plugin . 我在Linux环境上进行了快速测试,它与Envfile插件配合良好

Properties File Path: 属性文件路径:

/tmp/env.properties

File content: 档案内容:

TEST_STACKOVERFLOW = "my_value"

Build step: 建立步骤:

echo $TEST_STACKOVERFLOW

Result: 结果:

[workspace] $ /bin/sh -xe /tmp/hudson8256628035734643761.sh
+ echo '"my_value"'
"my_value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM