本文介绍了如何在 Jenkins/Hudson 中以编程方式设置环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Jenkins 作业的预构建步骤中有两个脚本,第一个是 perl 脚本,第二个是使用 groovy 插件的系统 groovy 脚本.我需要第二个 groovy 脚本中第一个 perl 脚本的信息.我认为最好的方法是设置一些环境变量,并想知道如何实现.

I have two scripts in the pre-build step in a Jenkins job, the first one a perl script, the second a system groovy script using the groovy plugin. I need information from the first perl script in my second groovy script. I think the best way would be to set some environment variable, and was wondering how that can be realized.

或者其他更好的方法.

感谢您的时间.

推荐答案

在构建步骤之间传播环境变量的方式是通过 EnvInject 插件.

The way to propagate environment variables among build steps is via EnvInject Plugin.

以下是一些以前的答案,展示了如何做到这一点:

Here are some previous answers that show how to do it:

但是,在您的情况下,在一个构建步骤中写入文件并在另一个构建步骤中读取该文件可能更简单.为确保您不会意外读取文件的先前版本,您可以在文件名中加入 BUILD_ID.

In your case, however, it may be simpler just to write to a file in one build step and read that file in another. To make sure you do not accidentally read from a previous version of the file you can incorporate BUILD_ID in the file name.

这篇关于如何在 Jenkins/Hudson 中以编程方式设置环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-20 02:42