Is there a way to checkout files from RTC using Ant scripts?. I have a scenario where i need to checkout the files from RTC and build an app using Ant.
It should be possible to invoke scm command through <exec> ant task.
You can see some examples in "Using the SCM Command Line Interface in builds"
<property name="run" value="/path/to/run_and_filter.pl"/>
<property name="scm" value="/path/to/scm"/>
<target name="__scm-checkin">
<!-- Do the initial commit -->
<exec executable="${run}" failonerror="true" outputproperty="cs">
<arg value="${scm} --non-interactive -a n -u y checkin ${roots}"/>
<arg value=" \(([^)]+)\)"/>
</exec>
<!-- Deliver -->
<exec executable="${scm}" failonerror="true">
<arg value="--non-interactive"/>
<arg value="deliver"/>
<arg value="${cs}"/>
</exec>
</target>
Make sure to use scm though, not lscm which starts a damon and can cause the ant task to hang: see "Calling lscm.bat from a build script causes a hang".
RTC does not have a "check-out" operation, which is implicit. It only has a check-in operation. If you want to get code from a repository workspace you can load it using scm command, as described before, or creating a java standalone using Plain API.
Related
In our project we are using a proprietary product which contains its own custom ant executable to build the deployment artifact.
So, we have two build files 'build-artifcat.xml' and 'build.xml'.
Here,
'build-artifcat.xml' - contains ant targets which can be executed with this products custom ant executable.
'build.xml' - contains ant targets which can be executed by Apache Ant.
We are using Bamboo CICD tool and this tool provides facility to execute only Apache Ant targets.
So, we are planning to use task to invoke ant targets from 'build-artifcat.xml' using this products custom ant executable.
I found below code while checking older projects but here I am not sure how can I specify the target to be executed from from 'build-artifcat.xml'.
Can you please help.
<target name="buildArtifact">
<echo>Running ant exec: ${run.custom.ant.exec}</echo>
<exec dir="${run.ant.exec.dir}" executable="${run.custom.ant.exec}" error="${basedir}/${error.log.file}">
<arg value="-f" />
<arg file="${basedir}/build-artifcat.xml" />
<arg value="-DimportDir=${import.location}" />
<arg value="-DartifactDir=${artifact.dir}" />
<arg value="-data" />
<arg value="${temp.workspace}" />
<arg value="-vmargs" />
<arg value="-Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./crashes/my-heap-dump.hprof -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:./crashes/gc.log" />
<arg value="-verbose" />
</exec>
</target>
As part of project, I prepared a Ant script which will download files from SVN and copy the files to remote server using scp.
But client asked me to copy only changed files from next deployment onwards in Jenkins instead of copying complete set of 20+ MB files.
got rsync command to do this but here the problem, how to send password from Ant
<exec executable="rsync" dir="/copy-files/js/" failonerror="true">
<arg value="-rcv"/>
<arg value="${username}#server:/media/js/"/>
</exec>
How to pass password from Jenkins, tried with RSYNC_PASSWORD and password-file options but not working.
You can pass values for environment variables by using nested env elements:
<exec executable="rsync" dir="/copy-files/js/" failonerror="true">
<arg value="-rcv"/>
<arg value="${username}#server:/media/js/"/>
<env key="RSYNC_PASSWORD" value="[your.password]" />
</exec>
With JMeter 3.0 Dashboard generation has become more interesting
and powerful.
a) How to use the following using 'Ant target' ?
jmeter -g /path/to/jtl/file -o /where/you/want/to/store/dashboard
b) How to Attach the Asset Validation Framework to the Dashboard.
This would help me generate Dashboard reports using Ant Tasks.
The easiest option would be to use ant's exec command.
<target name="generate-new-report">
<exec executable="${jmeter.home}/bin/jmeter.bat">
<arg value="-g"/>
<arg value="/path/to/jtl/file"/>
<arg value="-o"/>
<arg value="/where/you/want/to/store/dashboard"/>
</exec>
</target>
So I'm building a project with maven, and in this maven pom we have a reference to an ant build script. The maven pom triggers this ant build to build a project (an install of alfresco with mysql database and tomcat server packed up with it).
The issue seems to be when you try to set up a database for alfresco to use through the ant build. This is the part of the ant build.
<target name="createDatabase">
<exec spawn="false" executable="${mysql.home}/bin/mysql" failonerror="true">
<arg value="-u" />
<arg value="root" />
<arg value="-e" />
<arg value="source ${alfresco.home}\mysql\db_setup.sql" />
</exec>
</target>
I'm getting 'unknown command '\U' sent back to me as an error on this. Of course you can install the DB manually but I want it as part of this ant script. SOmeone I work with runs this successfully on XP, but I'm getting that error on win7. Any ideas?
I'm attempting to execute a program, and if that fails I have a fallback method to get the information required. Not everyone who uses this build script will have the program installed. My task has the following:
<exec executable="runMe"
failonerror="false"
failifexecutionfails="false"
outputproperty="my.answer"
errorproperty="my.error"
error="myerror.txt" />
Apparently I misunderstand the Ant manual because I thought by setting error or errorproperty the error would be redirected and not shown on the screen.
Is it possible to hide the message "Execute failed: java.io.IOException: Cannot run program "runMe"..."?
Alternately, is there a way to determine if that program can be run without checking for its existence? If the program is on the user's system it won't be in the same place from user to user.
Thank you,
Paul
Try ant-contrib's try/catch/finally commands.
http://ant-contrib.sourceforge.net/tasks/tasks/trycatch.html
The goal for doing this was to get the Subversion revision for my project in Ant. Some developers have command line Subversion installed and others don't so I needed a way to test for the presence of svnversion.
In the end I used a batch file to test the command:
REM File checkCommand.bat
#echo off
%1 >NUL 2 >NUL
if errorlevel 1 goto fail
REM command succeeded
exit 0
:fail
REM command failed
exit 1
In my Ant target I run this like so:
<target name="checkForSvnversion">
<local name="cmdresult" />
<exec dir="." executable="com"
resultproperty="cmdresult"
failonerror="false"
failifexecutionfails="false">
<arg line="/c checkCommand.bat svnversion" />
</exec>
<condition property="exec.failed">
<equals arg1="${cmdresult}" arg2="1" trim="true" />
</condition>
</target>
I have two targets that depend on this result:
<target name="getRevisionFromSvnversion" depends="checkForSvnversion"
unless="exec.failed">
etc etc
</target>
and
<target name="getRevisionFromEntries" depends="checkForSvnversion"
if="exec.failed">
etc etc
</target>
Finally, the task I call to get the revision is:
<target name="getRevision"
depends="getRevisionFromSvnversion,getRevisionFromEntries">
<echo>My rev is ${svn.revision}</echo>
</target>