SVN checkout under Linux using Ant - linux

When I run the build.xml in linux ubuntu, which should checkout the project from svn is giving the following error:-
svn:
BUILD FAILED
java.net.MalformedURLException: Invalid svn url: svn://xxx-xx-xx-xx-xx.compute-1.amazonaws.com/srv/svn
at org.tigris.subversion.svnclientadapter.SVNUrl.parseUrl(SVNUrl.java:117)
at org.tigris.subversion.svnclientadapter.SVNUrl.<init>(SVNUrl.java:63)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.apache.tools.ant.IntrospectionHelper$11.set(IntrospectionHelper.java:1069)
at org.apache.tools.ant.IntrospectionHelper.setAttribute(IntrospectionHelper.java:388)
at org.apache.tools.ant.RuntimeConfigurable.maybeConfigure(RuntimeConfigurable.java:392)
at org.apache.tools.ant.RuntimeConfigurable.maybeConfigure(RuntimeConfigurable.java:349)
at org.apache.tools.ant.UnknownElement.handleChild(UnknownElement.java:568)
at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:346)
at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:198)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:160)
Actually the path of svn is what I connect from my local box. So I don't know what path I shoul give here. The svn is in the same linux box.
My directory path where the build.xml is:-/home/ubuntu/antCheckout
And the path where svn is:-/srv/svn
I also tried this path:- ssh://srv/svn but exception was same.
This is my build.xml:-
<?xml version="1.0"?>
<project name="Test" default="Main" basedir=".">
<!-- Sets variables which can be used. -->
<property name="checkout" location="./svncheckout" />
<!-- Define the classpath which includes the jars
that are required for svnant.jar -->
<path id="/usr/local/ant/apache-ant-1.7.1/">
<pathelement location="lib/svnant.jar" />
<pathelement location="lib/svnClientAdapter.jar" />
<pathelement location="lib/svnjavahl.jar" />
<pathelement location="lib/svnkit.jar" />
</path>
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml"
classpathref="/usr/local/ant/apache-ant-1.7.1/" />
<!-- Deletes the existing build, docs and dist directory-->
<target name="clean">
<delete dir="${checkout}" />
</target>
<!-- Creates the build, docs and dist directory-->
<target name="makedir">
<mkdir dir="${checkout}" />
</target>
<!-- Checkout the latest source code of svnant itself-->
<target name="svn">
<svn username="guest" password="">
<checkout url="svn://srv/svn" revision="HEAD" destPath="${checkout}" />
</svn>
</target>
<target name="Main" depends="clean, makedir, svn">
<description>Main target</description>
</target>
</project>
Thanks for help.

If you're on Linux, do you have the Subversion command line client?
Try this:
$ svn --version
If you have the Subversion command line client, try this command:
$ svn ls svn://svn/srv
And see what you get. I bet you'll get an error telling you that svn://srv/svn isn't found or isn't a valid URL.
This line:
<checkout url="svn://srv/svn" revision="HEAD" destPath="${checkout}" />
Is equivalent to the command line:
$ svn checkout -rHEAD svn://srv/svn .svncheckout
You will have to find the valid Subversion repository URL before this command will work. Then, change the url parameter in the <checkout> sub-task to match that URL. Subversion uses URLs to point to the repository address.
By the way, exactly what is this suppose to be doing? Why is this checking out the working directory to the .svncheckout directory? That's a hidden directory in Unix.
By the way: svn co svn://127.0.0.1 isn't going to work unless the program snvserve is running on the local system. The svnserve program

Related

repo override remote URL of the element proejct without change

Is any repo sync option could override the remote URL by specified project
for example, I have locally kernel git repository and some hotfix, driver porting whatever
so I want to run such fake commnd without modified .repo/manifect.xml
repo sync --project-remote-url=git://my.server.ip/kernel.git
Try with local-manifests.
The local manifests will be combined with the default.xml. And you can adding or replacing projects in default.xml.
For example:
<manifest>
<!-- add github as a new remote source -->
<remote name="github" fetch="git://github.com" />
<!-- remove project in default.xml -->
<remove-project name="platform/bootable/recovery" />
<!-- replace with new remote github -->
<project path="bootable/recovery" name="CyanogenMod/android_bootable_recovery" remote="github" revision="cm-10.1" />
<!-- add new project -->
<project path="external/busybox" name="CyanogenMod/android_external_busybox" remote="github" revision="cm-10.1" />
</manifest>

ant: string manipulation on variable

I have a question based from this question
Replacing characters in Ant property
I want to build a variable (i can't use a property because i'm in a loop) that is pretty much StringA - StringB.
(maybe this is a misunderstanding of properties on my part but they can only be assigned once correct?)
I guess I could build a script function to calculate that, but my guess is that it must be possible to do it in an already existing function, probably something i'm missing.
this would be an example of the code
<for param="file">
<path>
<fileset dir="${mydir}" >
<include name="*.war"/>
</fileset>
</path>
<sequential>
<var name="undeploy_name" value="#{file} function_here ${mydir}" />
<JBossCLI port="${jboss.port.management-native}">
<undeploy namePattern="${undeploy_name}" />
</JBossCLI>
<deployToLiferay file="#{file}" />
</sequential>
</for>
in general I want to deploy several wars. this works fine when I run it once but if I want to make it re-runnable I need to undeploy them first.
I'm just a consumer of this interfaces, Ideally deployToLiferay would auto undeploy but it does not.
thanks for an feedback
edit: if I use something similar to what is define on the linked page i get:
<loadresource property="file-to-deploy">
<propertyresource name="#{file}"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replacestring from="${mydir}" to=""/>
</tokenfilter>
</filterchain>
</loadresource>
10:52:49.541: * /data/contribution.xml:171: The following error occurred while executing this line:
10:52:49.541: * /data/contribution.xml:178: null doesn't exist
line 178 is my loadresource part
ANT is not a programming language. Personally I'd recommend embedding a scripting language like Groovy to process a group of files:
<target name="process-files" depends="resolve">
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>
<fileset id="wars" dir="src/wars" includes="*.war"/>
<groovy>
project.references.wars.each {
ant.echo(message: "I want to do something with this ${it} file")
}
</groovy>
</target>
Example
├── build.xml
└── src
└── wars
├── app1.war
├── app2.war
└── app3.war
Example
process-files:
[echo] I want to do something with this /../src/wars/app1.war file
[echo] I want to do something with this /../src/wars/app2.war file
[echo] I want to do something with this /../src/wars/app3.war file
Update
The following working example shows how Apache ivy can be used to manage build dependencies. This is a capability that exists in other Java build tools like Maven.
<project name="demo" default="process-files" xmlns:ivy="antlib:org.apache.ivy.ant">
<available classname="org.apache.ivy.Main" property="ivy.installed"/>
<!--
==================
Normal ANT targets
==================
-->
<target name="process-files" depends="resolve">
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>
<fileset id="wars" dir="src/wars" includes="*.war"/>
<groovy>
project.references.wars.each {
ant.echo(message: "I want to do something with this ${it} file")
}
</groovy>
</target>
<!--
=============================
Dependency management targets
=============================
-->
<target name="resolve" depends="install-ivy">
<ivy:cachepath pathid="build.path">
<dependency org="org.codehaus.groovy" name="groovy-all" rev="2.4.7" conf="default"/>
</ivy:cachepath>
</target>
<target name="install-ivy" unless="ivy.installed">
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar"/>
<fail message="Ivy has been installed. Run the build again"/>
</target>
</project>

How to integrate xUnit.net with CruiseControl.net

I have a continuous integration server that discovers and runs assemblies with NUnit tests. I would like to add some assemblies with xUnit.net tests to the mix. How would I do that?
Download xunit-build-xyzw.zip from xUnit.net on CodePlex and extract it to, for example, C:\Program Files\xUnit.net. Add this location to PATH environment variable
be sure to have no trailing semicolon
Modify your CC.NET *.build script to discover assemblies by convention, as outlined below
note that command line argument syntax no longer has equals sign
In C:\Program Files\CruiseControl.NET\server\ccnet.config, Merge XML files produced by NUnit runner and by xUnit.net runner, as outlined below
merging happens after build, irrespective of build status
be sure results of test run get deleted in the beginning of build script
Restart CC.NET
Download xUnitSummary.xsl from xUnit.net on GitHub and place it in C:\Program Files (x86)\CruiseControl.NET\WebDashboard\xsl
In C:\Program Files\CruiseControl.NET\WebDashboard\dashboard.config, modify buildPlugins element as outlined below
Restart IIS
Additional info:
CruiseControl.Net – Server Installation at Neal's Blog
Step 2:
<project default="RunTests_xUnit">
<target name="RunTests_xUnit" description="Runs the discovered xUnit.net unit tests" depends="someCompileStep">
<!-- Outer loop to search through a list of different locations -->
<!-- Folders to be searched should listed as a semicolon deliminated list in the 'in' attribute -->
<foreach item="String" in="${TestAssemblyOutputPath}" delim=" ;" property="testsPath">
<echo message="Searching for xUnit.net test suites in ${testsPath}" />
<!-- Inner loop to search for dlls containing unit tests -->
<foreach item="File" property="filename">
<in>
<items basedir="${testsPath}">
<!-- see http://nant.sourceforge.net/release/0.91/help/types/fileset.html for how to include or exclude specific files or file patterns -->
<!-- attempt to run tests in any dlls whose name ends with UnitTestSuite.dll' -->
<include name="**UnitTestSuite.dll" />
</items>
</in>
<do>
<property name="testDLLName" value="${path::get-file-name-without-extension(filename)}" />
<echo message="Testing ${testDLLName} with xUnit.net" />
<exec program="${xunit-console.exe}" failonerror="true" resultproperty="resultVal">
<arg line="${testsPath}\${testDLLName}.dll /xml ${xUnitTestLogsFolder}${testDLLName}-xUnitResults.xml" />
</exec>
<fail message="Failures reported in ${testDLLName}." failonerror="true" unless="${int::parse(resultVal)==0}" />
</do>
</foreach>
</foreach>
</target>
</project>
Step 3:
<publishers>
<merge>
<files>
<file>C:\logs-location\xUnitTestLogs\*UnitTestSuite-xUnitResults.xml</file>
<file>C:\logs-location\TestLogs\*Tests-Results.xml</file>
</files>
</merge>
<xmllogger />
<statistics />
</publishers>
Step 5:
<buildPlugins>
<buildReportBuildPlugin>
<xslFileNames>
...
<xslFile>xsl\xUnitSummary.xsl</xslFile>
</xslFileNames>
</buildReportBuildPlugin>
...
<xslReportBuildPlugin description="xUnit.net Report" actionName="xUnitReport" xslFileName="xsl\xUnitSummary.xsl" />
...
</buildPlugins>

Create file that keeps time and revision number of my project when I compile

Currently the file is only keeping the latest revision. I want to use a different file where the history is kept. Each time ANT is used, I want it to append the time and revision number on that file. On the home screen I will just have a link to that file.
This is how its written now:
<target name="compile-java" depends="prepare,compile">
<exec dir="${project.dir}" executable="tools/version.sh" output="${src.web.dir}/date_compile.jsp">
<arg line="" />
</exec>
<propertyfile file="${src.web.dir}/date_compile.jsp">
</propertyfile>
</target>
I want to append new revision while keeping old revision data too.
This is just a matter of using the BuildNumber or PropertyFile task to create the build version number file and then read the file to get that number, create also a timestamp of the build and then append them both to another file.
Here is a basic idea of how to do it. Starting from that you should be able to write something of the likes of this:
<project default="increment">
<target name="increment">
<tstamp>
<format property="build.time" pattern="yyyy-MM-dd HH:mm:ss" />
</tstamp>
<propertyfile file="build.properties">
<entry key="build.number" type="int" operation="+" default="0" />
</propertyfile>
<property file="build.properties" />
<echo message="Build ${build.number} on ${build.time}
" append="true" file="build.history" />
</target>
</project>
This creates two files: build.properties with your build number (always the last number as it is overwritten on each build) and build.history that contains a list of build numbers and a timestamp of each build.
EDIT : Based on the comments, if the version.sh outputs the revision and date to date_compile.jsp and overrides it on each build then - to keep history - you just need to load date_compile.jsp in your build and append its content to another file, something like this:
<target name="compile-java" depends="prepare,compile">
<exec dir="${project.dir}" executable="tools/version.sh" output="${src.web.dir}/date_compile.jsp">
<arg line="" />
</exec>
<loadfile property="revision" srcfile="${src.web.dir}/date_compile.jsp" />
<echo message="${revision}<br>
" append="true" file="${src.web.dir}/compile_history.jsp" />
</target>
Not 100% sure what you want, but it looks like a combination of <tstamp/>, <echo>, and <propertyfile/>.
You can use <propertyfile> to specify the property file where the build number is stored, and for editing it:
<propertyfile file="${build.prop.file}">
<entry key="build.number"
value="1"
default="0"
operation="+"/>
</propertyfile>
Now, you can include that property file in your build:
<property file="${build.prop.file}"/>
Which will set ${build.number}.
Next, you're going to get the date and time:
<tstamp>
<format property="build.time.stamp"
pattern="yyyy-mmm-dd.hh:mm:ss-zzzzz"/>
</tstamp>
Now, you'll append this to your log file
<echo append="true" file="${build.log}"
message="Building build # ${build.number} on ${build.time.stamp}"/>

How to run a task before updating source files?

I need to run a task in CruiseControl .NET before checking for modification in source control. I mean this task should be the very first thing that CruiseControl will always do. I see
<prebuild> section in cc.config, but it is for running tasks before building a solution, so it is not exactly what I need.
Prebuild DOES fire before the source control get. It comes after the source control block but still fires first. Here's an example I've been using:
<cb:define subversionpath="c:\Program Files\Subversion\bin\svn.exe"
/>
<cb:define name="svn50">
<executable>$(subversionpath)</executable>
<workingDirectory>D:\Projects\B50\Source</workingDirectory>
<trunkUrl>svn://machineName/branches/B_50/Source</trunkUrl>
<autoGetSource>true</autoGetSource>
</cb:define>
<project name="StreamlineCheckBuild" queue="B50">
<triggers>
<intervalTrigger seconds="180" />
</triggers>
<sourcecontrol type="svn">
<cb:svn50/>
<deleteObstructions>true</deleteObstructions>
<forceUpdate>true</forceUpdate>
</sourcecontrol>
<prebuild>
<exec>
<executable>$(subversionpath)</executable>
<buildArgs>cleanup</buildArgs>
<baseDirectory>D:\Projects\B50</baseDirectory>
</exec>
</prebuild>
<tasks>
...
</tasks>
</cruisecontrol>
Use batch file as proxy for the version control utility, eg. svn.bat:
echo do stuff
"c:\program files\Subversion\svn.exe" %*
Use executable atrribute to point to the bach file.

Resources