Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Ant Task "Target" field too short, how can i pass more variables?

Tomas Buzga November 20, 2012

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?

2 answers

1 accepted

0 votes
Answer accepted
Tomas Buzga November 20, 2012

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

0 votes
Radu Dumitriu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 20, 2012

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}"/>

Tomas Buzga November 20, 2012

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

Tomas Buzga November 20, 2012

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.

Radu Dumitriu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 20, 2012

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>

Tomas Buzga November 20, 2012

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 ?

Radu Dumitriu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 20, 2012

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.

Tomas Buzga November 20, 2012

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events