How to set a global property file so that contain the defined properties are getting resolved during my ANT build in Intelliji IDEA?
In Eclipse I can do this via the "Properties" tab in the "Window/Preferences/Ant/Runtime" config.
How can I set this in Intellij IDEA 9 or 10 ?
IDEA allows you to specify custom properties for the build script, but not via file:
Use this tab to specify the runtime properties that should be passed to the build script. These properties are equivalent to the ones defined after the -D option of the command line. A property is defined as a pair "name-value". The value can be hard-coded, or dynamically evaluated at runtime from a macro.
If you want to use a file, then you need to reference properties file from the build.xml:
Alternatively you can execute the Ant build script on the command shell (View > Tool Windows > Terminal). The command ant can load specific property files, e.g.: <property file="./resources/build.properties" />.
Related
I have 2 properties files as below
a.properties has list of property names
b.proprties has list of its corresponding values
a.properties
Application=
ApplicationID=
BU=
b.properties
ACCSRV
ACCSRV
BT
I am looking for ant script which can give me final properties file with out out as below:
Final.properties:
Application=ACCSRV
ApplicationID=ACCSRV
BU=BT
Sounds like you need an external tool for this. If you can depend on unix tools, you can use the paste command (see man paste) and run it from ant using the exec task. If not, you can either
write the tool in java, then use tasks javac and java to compile and run it from ant
or use the script task to embed the tool in your ant script using some scripting language
I am invoking a windows batch command from Jenkins, after i get the latest version of my project from SVN. the windows batch command just performs certain file copying, after the all the files are retrieved from SVN and runs an ANT build. In the ANT build process, i am generating a JSP file where i have tried to capture the in the following fashion.
%BUILD_TAG%-%BUILD_NUMBER%-%BUILD_ID%-%SVN_REVISION%
Unfortunately none of this information is understood by the build process and it just writes %BUILD_TAG%-%BUILD_NUMBER%-%BUILD_ID%-%SVN_REVISION% into the file.
Could you please let me know if there is a way to capture these information into a file in the way i am trying to do? if not, could you direct me on how these information could be captured into a JSP file during the process that we are following?
BUILD_TAG, SVN_REVISION, etc are all environment variables that are present during a Jenkins build, and to use them in Ant, you would use them as any other environment variable from Ant
First, add a line:
<property environment="env"/>
Then you can reference any environment variable with this prefix, like:
${env.VAR_NAME}
So in your case, you'd do:
${env.BUILD_TAG}-${env.BUILD_NUMBER}-${env.BUILD_ID}-${env.SVN_REVISION}
Dos it exist a way to propagate java system property from Tomcat to jenkins ant task?
Particularly I would like to propagate catalina.home property to ant task. When trying catalina.home=${catalina.home} I get error Property catalina.home was circularly defined.
so you want catalina.home of the tomcat that's running jenkins passed into your ant build?
hmmm... I'm not sure it's goign to work, but try setting the catalina.home property to the value of the CATALINA_HOME environment variable:
catalina.home=${evn.CATALINA_HOME}
It likely won't work, you'll want to see what you set CATALINA_HOME environment variable is and just pass that into your ant build:
ant -Dcatalina.home="/usr/share/tomcat7
I don't think you have direct access from your job configuration to your system properties. You will need to write your own plugin to read out the system properties.
Check if you have CATALINA_HOME available. If you do, pass it into ant (ant plugin has a field for that) or set it within your ant-script like thekbb suggested. catalina.home=${evn.CATALINA_HOME}
For some GUI testing I'm creating a Jenkins task for each GUI module to be tested.
Once created I'm using Ant to build these tests, but I'm not aware of how to actually pass parameters from Jenkins to Ant build file? Basically how do I do variable substitution in Ant?
I'm using the Sahi framework to test GUI components, so the flow goes like this...
Jenkins → Ant build script → Sahi file to execute
Can anyone please take a look at it?
"Using ant -Dname=value lets you define values for properties on the Ant command line." http://ant.apache.org/faq.html#passing-cli-args
To use a jenkins parameter as a variable when you call any use ${variablename}
https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build
Click Advance under configure section of your job in jenkins and use "Properties" section to pass parameter value to Ant script.
e.g
jenkins.param=10
ant.prop=$jenkins.param where jenkins.param is the parameter defined in the jenkins job .
Now in your ant build script ,you can get the value by using ${ant.prop}.
From Jenkins to SAHI Pro via ANT.
In the ant target that you call from Jenkins, give the following within sahi tag.
<customfield key="variable_name" value=" variable _value"/>
Now, such values from Jenkins will be available in SAHI Pro through the ant target. To retrieve them in SAHI, you should set them in “CUSTOM_FIELDS” of testrunner file.
For example:
SET CUSTOM_FIELDS= -variable_name jenkinsToSahiVariable
Where -variable_name should be same key that you set in ant target. And second string will contain the value you set from Jenkins. To get this in a sahi file, use sahiSuite API like following.
$jenkinsValues = _suiteInfo();
$sahiVariable = $ jenkinsValues ["jenkinsToSahiVariable"];
consider the following example:
<project basedir="${env.DIR}">
...
</project>
Is it possible to access an environment variable in the project element along these lines?
No you can't. Neither can you use a property there. You have to change them from the way you call your build file. E.g. if you call it with another ant task , you can set the basedir attribute there.
If you call your build file from Eclipse, to set the Base Directory property from the task that runs the ant build file you can:
Right click on the build file
Choose "Run As" -> "External Tool Configurations..."
Under the "Main" tab, use the Base Directory box to enter the directory, but note the syntax of defining an environment variable here, for example if your environment variable is named "DIR", it would be: ${env_var.DIR}