How can I get ant input argument in commandline in build xml???
I have command:
C:\> Ant TestApp WebAppUSA WebSvcEurope -Denv dev
In build.xml, I hope to get these three arguments values:
TestApp
WebAppUSA
WebSvcEurope
separately,
How to get these arguments values in build xml???
Thanks so much
This can be done with the -Dproperty=value option, where property is the name of the property, and value is the value for that property.
Related
I need to pass parameter values to jmeter properties like this:
#echo off
cd E:\apache-jmeter-2.11\bin
jmeter.bat -n
-t E:\OMS.P01-AccountCreation.jmx
-l E:\result.csv
-j E:\jmeter.log
-Jthreadgroup.count=1
-JPRIMARY_STREET_NUMBER=1234
-JPRIMARY_STREET_NAME=DONALDTRUMP AVENUE
But this will fail as the name 'DONALDTRUMP AVENUE' has an space. It will try to read 'AVENUE' as a different parameter. Is there any way to make it read as a whole value? thanks
EDIT
It works if I add "" to enclose it. However, when I try the same thing with ANT, it throws the same error. Does anyone knows how can I solve it?
EDIT 2
I tried again with command line instead of ant. I think I found the problem. I cant add too many parameters (I'm adding like 22 parameters) I'm not sure if there is a parameter limit or if there is a length limit for the whole command line.
I don't know how you're passing properties to Ant but normally smart people don't have any problems with spaces in property values. Are you aware that:
Ant doesn't know anything regarding -J command line argument
Ant knows nothing about JMeter properties
So if you need to pass to JMeter something you can change via Ant command-line you need to do something like:
In build.xml
<target name="jmeter">
<jmeter
jmeterhome="/path/to/your/jmeter"
testplan ="OMS.P01-AccountCreation.jmx"
resultlog="result.jtl">
<property name="jmeter.save.saveservice.output_format" value="xml"/>
<property name="jmeter.save.saveservice.assertion_results" value="all"/>
<property name="jmeter.save.saveservice.bytes" value="true"/>
<property name="threadgroup.count" value="${threadgroup.count}"/>
<property name="PRIMARY_STREET_NUMBER" value="${PRIMARY_STREET_NUMBER}"/>
<property name="JPRIMARY_STREET_NAME" value="${PRIMARY_STREET_NAME}"/>
</jmeter>
</target>
When launching JMeter test via Ant:
ant -Dthreadgroup.count=1 -DPRIMARY_STREET_NUMBER=1234 -DPRIMARY_STREET_NAME="DONALDTRUMP AVENUE"
References:
Command prompt (Cmd. exe) command-line string limitation
Five Ways To Launch a JMeter Test without Using the JMeter GUI
I'm creating a target in the build.xml file which depends on three other targets:
<target name="test" depends="target1,target2,target3">
<echo message="Build Successful!"/>
</target>
What I'm trying to do here is to pass some argument to 'target2'. Can this be done in Ant? If so, how can I do it?
Any help is truly appreciated!!
Do you understand how depends works?
When you call target test, it will run the following targets:
target1
target2
target3
test
In that order. There's no way for target test to pass any arguments to target2.
You can pass properties to your build.xml script using the -D parameter:
$ ant -Dsource.version="1.5" compile
When your build script is executed, the property source.version will be set to 1.5.
Otherwise, look at macrodef task as a way of passing arguments to particular routines.
By the way, if I had more information what you want, I could give you a better answer.
I'm trying to use Ant 1.7 but running into a problem. In my current directory, I have a build file called warupdate.xml. From within this directory, I execute:
/opt/apache-ant-1.7.0/bin/ant -f warupdate.xml
I then get the following error:
Buildfile: warupdate.xml
BUILD FAILED
./warupdate.xml is not an absolute path
Any ideas? Thanks!
Matt
Why name it anything other than build.xml? It's the standard, ant will expect it and then you can simply just run ant from that directory without specifying a build file.
Here's my warupdate.xml:
<project>
<echo>Tada!</echo>
</project>
Here's my Ant command:
$ /opt/ant/bin/ant -f warupdate.xml
Buildfile: /Users/david/warupdate.xml
[echo] Tada!
BUILD SUCCESSFUL
Total time: 0 seconds
Basically, it works.
Something else is going on, and you're not giving the full story. What does warupdate.xml look like? What if you use ant -d to get a verbose debugging output. Maybe that will show you what's going on. Why are you giving the full path to ant?
You have to give us more information.
I have following code in config.xml file:
<schedule interval = "300">
<ant anthome="/usr/share/ant"
antworkingdir="${GitDir}"
uselogger="true"
usedebug="true"/>
</schedule>
And when I execute build through it, I am just getting output, like I've been typing just ant in command line.
I need to be able to execute following command from Cruisecontrol:
ant debug
If this is making any difference, I need to be able to build android application.
How this can be done?
Thank you on advance.
You're already using the right attributes in your config.xml to start your ant scripts with loglevel debug
...
usedebug="true"
...
is equivalent to ant -debug ...
see http://cruisecontrol.sourceforge.net/main/configxml.html#ant for details.
does anyone knows how to set additional environment variables for an ant script from within intellij-idea/rubymine? The part of the ant script which uses the environment variable looks as below:
<property environment="env"/>
<fail unless="env.IDEA_HOME" message="IDEA_HOME must be set."/>
What I've tried so far:
Passing an environment variable on startup to intellij
Settings -> Path Variables
Ant Build -> Properties
Ant Build -> Execution -> Ant command line
You can set variables as additional command line parameters. Here is a screenshot.
And then my output:
echoproperties
#Ant properties
#Sun Mar 04 04:48:30 EST 2012
\==-buildfile
ant.core.lib=E\:\\IntelliJ IDEA 114.145\\lib\\ant\\lib\\ant.jar
ant.file=E\:\\IdeaProjects\\psiviewer\\build.xml
ant.file.psiviewer=E\:\\IdeaProjects\\psiviewer\\build.xml
ant.file.type=file
ant.file.type.psiviewer=file
ant.home=E\:\\IntelliJ IDEA 114.145\\lib\\ant
ant.java.version=1.6
ant.library.dir=E\:\\IntelliJ IDEA 114.145\\lib\\ant\\lib
ant.project.default-target=all
ant.project.name=psiviewer
ant.version=Apache Ant(TM) version 1.8.2 compiled on December 20 2010
awt.toolkit=sun.awt.windows.WToolkit
basedir=E\:\\IdeaProjects\\psiviewer
dir.idea=e\:/idea11
file.encoding=windows-1252
file.encoding.pkg=sun.io
You see dir.idea is set to what we passed to ant.
Problem: Run ant build within IntelliJ, let ant build property to use IntelliJ Path Variables value
Solution:
Added path variable QC1_SHELL_DEPLOY to intelliJ
IntelliJ Settings ->Path Variables
In your Ant Build window (views -> Tool Windows -> Ant Build),
right click on your ant script (assuming you have one added), click properties.
create a property for ant script qc_deploy_dir.
property for ant script with arbitrary value
Open ant.xml in your project .idea/ant.xml, change the line defining qc_deploy_dir to use IntelliJ Path Variable $QC1_SHELL_DEPLOY
Go back to your properties window for ant script, now qc_deploy_dir is picking up QC1_SHELL_DEPLOY value.