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

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

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

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

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

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.

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>

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 ?

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.

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Friday in Off-topic

Friday Fun: Riddle me this

Happy Friday, Funmakers! We had a Community Team offsite in Austin this week, and my mind feels primed for thinkin' from all the brainstorming we did!  So, this week's Friday Fun thread w...

144 views 19 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you