Ant Task "Target" field too short, how can i pass more variables?
Asked by Tomas Buzga:

I am using capability variables to set various paths and executables used during build process.  
The reason for that is, these paths and executables can be different (different paths) on each agent, and using capabilities seemed to be a convenient way.

The problem is that the Ant Task "Target" field is rather limited in character length and its content gets clipped, so i am unable to pass all needed variables to Ant.

Is there other way of passing Bamboo variables to Ant?


Answers:
author: Tomas Buzga
body: There is a task plugin "Marvelution Bamboo Variables Stamper".  
It saves Bamboo variables into a file, so they can be used by other tasks.


author: Radu Dumitriu
body: Using the following tecnique may help:

`ant deploy -Dbuild.host=X`

... and in your ant ...

    <conditionproperty="build.host.propfile"value="X-host.properties"><equalsarg1="build.host"arg2="X"/></condition>
    <conditionproperty="build.host.propfile"value="Y-host.properties"><equalsarg1="build.host"arg2="Y"/></condition>
    <property file="${build.host.propfile}"/>


comments: author: Tomas Buzga
body: You mean to put "ant deploy -Dbuild.host=X" into the Ant Task "target" field?

Thats exactly what i am doing and it doesnt work, because the "target" field has limited length, so i cannot put ALL needed variables into it - the resulting string is just too long and gets clipped.

So i am asking if there is some other way to pass Bamboo variables to Ant


author: Tomas Buzga
body: Thank you, this will of course work, but if i would have to use propfiles, then i would just place appropriate propfile on each agent and be done with it.

Isn't there any other way, without the need of having propfiles with predetermined content?  
I like the idea of using variables, which can be set differently for each agent, and the setting can be done via Bamboo administration instead of editing files on each agent.


author: Radu Dumitriu
body: You do not need to use prop files. You can modify it to directly set up properties using conditional targets, for instance. Or use the <http://ant-contrib.sourceforge.net/> to create the \<if\>


author: Tomas Buzga
body: I still dont get it, so let me rephrase my question:

Let's say i have capability variable "Bamboo.capability.something" containing "b:\\somepath\\somewhere\\something".  
How do i pass this variable value to Ant, without adding " -Dsomething=${bamboo.capability.something}" in the Ant Task target field ?


author: Radu Dumitriu
body: Sorry, I do not know other way to pass it.

I keep all my agents config files in SVN and provided reasonable defaults to properties as well, in the manner I shown you. In this way:

1/ You have a versioned props file for each agent (and that's good, IMHO)

2/ Disadvantage is of course that creating the build is not the only thing you must do, you must craete the properties file as well

BUT: you can alleviate it. Example: instead of passing full paths ("b:\\somepath\\somewhere\\something", "b:\\somepath\\somewhere\\somethingelse"), you pass only the root ("b:\\somepath\\somewhere") and deduct them, etc.

I understand what you want, but I do not know any other way to do it.


author: Tomas Buzga
body: Thank you very much, it looks like i want something thats not possible.  
I am thinking about maybe writing a task plugin to export the variables into a file, which could be then imported.


Tags: ant

variable