如何在 Jenkins 中设置环境变量? [英] How to set environment variables in Jenkins?
问题描述
我希望能够做类似的事情:
I would like to be able to do something like:
AOEU=$(echo aoeu)
并让 Jenkins 设置 AOEU=aoeu
.
and have Jenkins set AOEU=aoeu
.
Jenkins 中的 环境变量 部分没有这样做.相反,它设置 AOEU='$(echo aoeeu)'
.
The Environment Variables section in Jenkins doesn't do that. Instead, it sets AOEU='$(echo aoeu)'
.
如何让 Jenkins 评估 shell 命令并将输出分配给环境变量?
How can I get Jenkins to evaluate a shell command and assign the output to an environment variable?
最终,我希望能够将作业的执行程序分配给一个环境变量,该环境变量可以传递给其他脚本或供其他脚本使用.
Eventually, I want to be able to assign the executor of a job to an environment variable that can be passed into or used by other scripts.
推荐答案
这可以通过 EnvInject 插件 方式如下:
This can be done via EnvInject plugin in the following way:
创建一个运行的执行 shell"构建步骤:
Create an "Execute shell" build step that runs:
echo AOEU=$(echo aoeu) > propsfile
创建一个注入环境变量构建步骤并将属性文件路径"设置为propsfile
.
Create an Inject environment variables build step and set "Properties File Path" to propsfile
.
注意:此插件(大部分)与 Pipeline 插件不兼容.
Note: This plugin is (mostly) not compatible with the Pipeline plugin.
这篇关于如何在 Jenkins 中设置环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!