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

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

问题描述

Jenkins参数是否区分大小写?我有一个参数化的构建,需要在构建之前设置一个名为"build_parameter"的蚂蚁参数.当我尝试访问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 build步骤来启动您的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天全站免登陆