Friday 15 May 2015

Calling Ant targets dynamically in Jenkins -


Is there any way to dynamically call ant targets in the 'Anti-Action Build' step? Let's say you have build.xml:

  & lt; Target name = "1" description = "1" & gt; & Lt; Exec Executable = "$ {RES_DIR} /1.sh" Failure = "True" & gt; & Lt; / Executive & gt; & Lt; / Target & gt; & Lt; Target name = "2" description = "2" & gt; & Lt; Exec Executable = "$ {RES_DIR} /2.sh" Failure = "True" & gt; & Lt; / Executive & gt; & Lt; / Target & gt; & Lt; Target name = "3" description = "3" & gt; & Lt; Exec Executable = "$ {RES_DIR} /3.sh" Failure = "True" & gt; & Lt; / Executive & gt; & Lt; / Target & gt;   

And you want your Jenkins to use the same build .xml, but to be able to make some target calls for each build. I do not want to hardcode these goals every time a project needs to be made because I want it to be done automatically, is it possible or do you already have to make a project and manually install your ant goals Have to set up?

attribute target s for a simple example

  & lt; The trick can be to use the target name = "run" dependent = "1,2,3" /> & Lt; Target name = "1" description = "1" if = "run1" & gt; & Lt; Exec Executable = "$ {RES_DIR} /1.sh" Failure = "True" & gt; & Lt; / Executive & gt; & Lt; / Target & gt; & Lt; Target name = "2" description = "2" if = "run2" & gt; & Lt; Exec Executable = "$ {RES_DIR} /2.sh" Failure = "True" & gt; & Lt; / Executive & gt; & Lt; / Target & gt; & Lt; Target name = "3" description = "3" if = "run3" & gt; & Lt; Exec Executable = "$ {RES_DIR} /3.sh" Failure = "True" & gt; & Lt; / Executive & gt; & Lt; / Target & gt;   

In this way, you call target run and set a criteria value to property runX (true usually Is a good option). Only the target X will actually move.

No comments:

Post a Comment