如何配置 Jenkins 以使用 ant 和自定义 args 构建项目 [英] How to configure Jenkins in order to build project using ant and custom args

查看:53
本文介绍了如何配置 Jenkins 以使用 ant 和自定义 args 构建项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 ant 构建下一个项目版本的程序太多了.该例程位于多个属性文件中,在运行 ant 任务之前必须对其进行编辑.我将 Jenkins 视为构建构建(包括夜间构建)的系统,但我在更改属性时遇到了问题.

There's too much routine with building next project version using ant. The routine is in several properties files that must be edited before running ant task. I took a look at Jenkins as a system to make builds (including night ones) but I have a problem with changing properties.

是否有可能(如果是,我该怎么做)在构建之前在 Jenkins 配置中键入参数以便将它们传递给 ant?

Is it possible (if yes, how can I do it) to type parameters in Jenkins configuration before build in order they will be passed to ant?

我真正的意思是以下架构(我在手动构建中使用):

What I really mean is the following schema (I used in manual builds):

  • 有 2 个属性文件,其中包含有关构建版本、src 目标、通知新构建的电子邮件等数据.

  • there're 2 properties files that contain data about build version, src destination, emails to notify about new build and so on.

在 Ant 任务中使用相应的属性键,这些属性在构建之前手动更改.

corresponding properties' keys are used in Ant tasks and these properties are changed manually before build.

某些属性由 Java util 读取,并在构建期间用于它们自己的部分.

some properties are read by Java util and used for their own part during build.

在 build.xml 中还导入了 3 或 4 个 ant XML,这些 xml 还从提到的文件中读取属性.

there're also 3 or 4 ant XMLs that a imported in build.xml, and these xmls also read properties from mentioned files.

我想做的是:

  • 更改 Jenkins 中的关键属性

  • change key properties in Jenkins

按构建项目

我的数据将覆盖属性文件中的数据,或者将作为 ant vars 值直接传递给 ant 的任务.

my data will overwrite data in properties files OR will be passed as ant vars values straight to the ant's task(s).

因此,我收到了带有相应通知的新版本(它们是通过 ant 发出的)

as a result I receive new build with corresponding notifications (they're made through ant)

是否存在允许通过 Jenkins 使这种模式工作的机制?

Are there mechanisms that allow one to make such schema work via Jenkins?

提前致谢.

推荐答案

在 Jenkins 中,您可以使用 参数化构建 功能,用于指定您需要替换到构建中的参数.

In Jenkins, you can use the parameterised build feature to specify those parameters you need to substitute into your build.

例如,如果指定一个名为 server 的参数,并且在单击立即构建"时输入 test,则构建将使用环境变量执行,您可以访问称为 ${server}.

For example, if specify a parameter called server and, when clicking "Build Now", you enter test, the build will be executed with an environment variable you can access called ${server}.

然后,在您的调用 Ant"构建步骤中,如果您按 Advanced...,这将显示一个属性"字段.在这里你可以输入my.ant.property=${server}.
这相当于调用了ant -Dmy.ant.property=${server},并且会扩展为ant -Dmy.ant.property=test.

Then, in your "Invoke Ant" build step, if you press Advanced..., this reveals a "Properties" field. Here you can enter my.ant.property=${server}.
That's equivalent to calling ant -Dmy.ant.property=${server}, and will be expanded to ant -Dmy.ant.property=test.

这篇关于如何配置 Jenkins 以使用 ant 和自定义 args 构建项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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