Jenkins - 如何访问 BUILD_NUMBER 环境变量 [英] Jenkins - How to access BUILD_NUMBER environment variable

查看:71
本文介绍了Jenkins - 如何访问 BUILD_NUMBER 环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jenkins 参数是否区分大小写?我有一个参数化构建,它需要在构建之前设置一个名为build_parameter"的 ant 参数.当我尝试访问 Jenkins 设置的 ${BUILD_NUMBER} 时,我获得了为 ant 参数设置的值.如果构建参数不区分大小写,有人可以建议我解决此问题吗?我无法更改构建参数名称,因为我必须更改构建脚本(这不是一个选项).谢谢!

Are Jenkins parameters case-sensitive? I have a parametrized build which needs an ant parameter named "build_parameter" to be set before the build. When I try to access the ${BUILD_NUMBER} set by Jenkins, I get the value set for the ant parameter. If the build parameters are not case sensitive, can anyone suggest me a work around to this issue? I cannot change the build parameter name as I will have to change my build scripts (which is not an option). Thanks!

推荐答案

要回答您的第一个问题,Jenkins 变量区分大小写.但是,如果您正在编写 Windows 批处理脚本,则它们不区分大小写,因为 Windows 不关心大小写.

To Answer your first question, Jenkins variables are case sensitive. However, if you are writing a windows batch script, they are case insensitive, because Windows doesn't care about the case.

由于您对自己的设置不是很清楚,让我们假设您正在使用 ant 构建步骤来启动您的 ant 任务.查看 Jenkins 文档(Adarsh 给您的同一页面,但不同的章节)有关如何使 Jenkins 变量可用于您的 ant 任务的示例.

Since you are not very clear about your setup, let's make the assumption that you are using an ant build step to fire up your ant task. Have a look at the Jenkins documentation (same page that Adarsh gave you, but different chapter) for an example on how to make Jenkins variables available to your ant task.

因此,我需要访问环境变量 ${BUILD_NUMBER} 来构建 URL.

Hence, I will need to access the environmental variable ${BUILD_NUMBER} to construct the URL.

那你为什么不使用 $BUILD_URL 呢?扩展电子邮件插件中没有吗?

Why don't you use $BUILD_URL then? Isn't it available in the extended email plugin?

这篇关于Jenkins - 如何访问 BUILD_NUMBER 环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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