如何使用詹金斯参数构建? [英] How to use Jenkins parameterized builds?

查看:353
本文介绍了如何使用詹金斯参数构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

詹金斯允许你建立参数,但我无法弄清楚如何真正利用它:

Jenkins allows you to parameterize builds, but I can't figure out how to actually make use of it:

说我通常会踢我的蚂蚁在命令行,像这样建了:

Say I would normally kick my Ant build off from the command-line like so:

ant -buildfile /path/to/my/build.xml -DpackageType=jar package

这将调用的build.xml 目标,并进行了命名属性 packageType 向它提供的,与罐子值

This would invoke the build.xml's package target, and make a property named packageType available to it, with a value of jar.

我假设在上面的截图中,命名字段是在那里我会指定 packageType ,但什么价值?

I'm assuming that in the screenshot above, the Name field is where I would specify packageType, but what about the value?


  1. 如果詹金斯希望我指定默认值作为属性,那么我在哪里指定我的项目使用的价值?例如,我可能希望默认值,但在罐子值这个詹金斯工作通(覆盖默认设置)。

  2. 此外,什么是詹金斯所说的...的允许用户节省打字的实际​​值。的哪些用户?你会在哪里,反正键入值?

  1. If Jenkins wants me to specify a Default Value for the property, then where do I specify the value that my project is using? For instance, I might want a Default Value of war, but have this Jenkins job pass in a value of jar (to override the default).
  2. Also, what does Jenkins mean by "...allows the user to save typing the actual value." Which user? Where would you type the value anyways?

在此先感谢!

推荐答案

每当用户在配置一个詹金斯构建参数化,参数的名字取为环境变量

Whenever the user configures a parameterised build in Jenkins, the parameter name is taken as an environment variable

用户可以使用使用环境变量等参数。结果

The user can make use of such parameters using the environment variable.

例如,你的情况,如果 packageType 是要传递的参数,结果

For example, in your case if packageType is the parameter you want to pass,

然后指定名称为 packageType 和值

您可以在您需要为 %packageType%

You can use it in the script you required as %packageType%

在配置作业后,每当你现在点击Build按钮,詹金斯提示输入参数

After configuring the job, whenever you click the build now button, Jenkins prompts for the parameter

当您使用文件参数,上传的文件将被放置在工作目录

When you are using file Parameter, the uploaded file will be placed into the working directory

这篇关于如何使用詹金斯参数构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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