Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Jenkins in order to build project using ant and custom args

Tags:

jenkins

ant

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.

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):

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

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

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

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

What I want to do is:

  • change key properties in Jenkins

  • press build project

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

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

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

Thank you in advance.

like image 449
Dragon Avatar asked Dec 21 '22 17:12

Dragon


1 Answers

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

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}.

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.

like image 168
Christopher Orr Avatar answered May 21 '23 14:05

Christopher Orr