How to execute the Environment Variables (env.) from Teamcity in Nant script - teamcity

I am using TeamCity to build the.Net Solution using Nant script and everything works fine if I hard Code the solution path. I want to use Environment Variables from TeamCity (env.) to be used as Solution Path -->env.solution.path----- C:\a\testteamcity\Demo\deptest.sln inside Nant script test.build file:
<?xml version="1.0"?>
<project name ="first Nant file" default="compile-solution" >
<property name="bin.folder.svn" value="C:\a\testteamcity\Demo\bin123"/>
<property name="bin.folder.sln" value="C:\cicheckout\webapp\bin"/>
<target name="compile-solution">
<exec program="C:\Program Files (x86)\MSBuild\12.0\Bin\Msbuild.exe" verbose="true" >
<arg line="${environment::get-variable('env.solution.path')}" />
<arg value="/p:Configuration=Release" />
</exec>
<copy todir="${bin.folder.sln}" overwrite="true" failonerror="true">
<fileset basedir="${bin.folder.svn}">
</fileset>
</copy>
</target>
</project>
Error:Unexpected token 'Punctuation'.
Expression: ${environment::get-variable(‘env.solution.path’)}
Any Help would be great.Thanks

Create system.solution.path --> C:\a\testteamcity\demo\deptest.sln under System Properties (system.) in Teamcity and in Nant script-->
<?xml version="1.0"?>
<project name ="Build-Solution" default="build-solution" >
<property name="solution.path" value="${system.solution.path}" dynamic="true" unless="${property::exists('solution.path')}"/>
<!-- Build solution -->
<target name="build-solution">
<exec program="C:\Program Files (x86)\MSBuild\12.0\Bin\Msbuild.exe" verbose="true" >
<arg line="${solution.path}" />
<arg value="/p:Configuration=Release" />
</exec>
</target>
</project>

Related

Weblogic WsdlcTask for gradle

I am looking for the weblogic.wsee.tools.anttasks.WsdlcTask for gradle. All I could find so far was an example for Ant.
Importing the ant script with ant.importBuild "wsdlc_build.xml" works perfectly fine in my gradle build script, but I would prefer writing the task in gradle. Has someone already found a solution for this?
My ant script:
<project name="WebServices" basedir=".">
<property name="build.wls.home" value="C:\User\wls\"/>
<path id="weblogic.tools.path">
<fileset dir="${build.wls.home}/wlserver/server/lib">
<include name="weblogic.jar" />
</fileset>
</path>
<taskdef name="wsdlc" classname="weblogic.wsee.tools.anttasks.WsdlcTask" classpathref="weblogic.tools.path"/>
<target name="build_opera">
<wsdlc failOnError="true"
srcWsdl="WebContent/WEB-INF/wsdls/OperaService.wsdl"
destImplDir="src"
destJwsDir="WebContent/WEB-INF/lib"
packageName="server.opera.webservice.service"
verbose="on" debug="on"
type="JAXWS">
</wsdlc>
</target>
<target name="build_nez">
<wsdlc
failOnError="true"
srcWsdl="WebContent/WEB-INF/wsdls/NezService.wsdl"
destImplDir="src"
destJwsDir="WebContent/WEB-INF/lib"
packageName="server.nez.webservice.service"
srcPortName="NezSoapPort"
type="JAXWS">
</wsdlc>
</target>
<target name="build_nezp">
<wsdlc
failOnError="true"
srcWsdl="WebContent/WEB-INF/wsdls/NezpService.wsdl"
destImplDir="src"
destJwsDir="WebContent/WEB-INF/lib"
packageName="server.nezp.webservice.service"
srcPortName="NezPSoapPort"
type="JAXWS">
</wsdlc>
</target>

OSX - Create .app file using ant

I have written an app in Objective-C for running it on Mac(OSX not iOS). I want to use it for direct distribution. In XCode, I can create .app file using Product -> Archive -> Distribute.
How do I create .app file using ant?
I found the answer myself. My ant.xml is as follows
<project name="MacAgent" default="MacCompile">
<property name="keychain.password" value="my_password"/>
<property name="user" value="my_username"/>
<property name="project.id" value="my_project_name"/>
<property name="xcodeHome" value="/Applications/Xcode.app/Contents/Developer"/>
<target name="MacCompile">
<exec executable="security">
<arg value="unlock-keychain"/>
<arg value="-p"/>
<arg value="${keychain.password}"/>
<arg value="/Users/${user}/Library/Keychains/login.keychain"/>
</exec>
<exec executable="${xcodeHome}/usr/bin/xcodebuild">
<arg value="-project"/>
<arg value="${project.id}.xcodeproj"/>
<arg value="clean"/>
<arg value="build"/>
</exec>
</target>
</project>

Zipping sub folders into separate zip files

I have a directory structure like this:
Parent
|->A
|->B
|->*
and I need to zip it like so:
Dest
|->A.zip
|->B.zip
|->*.zip
Where the * means that I don't know what are the names of the sub-folders.
How can I do this?
I'm working with a maven project but I don't mind using the antrun plugin
Here is another solution that I like since it doesn't require antcontrib:
<target name="zipContentPackage">
<basename property="dir.name" file="${file_name}"/>
<echo message="Zipping folder: ${dir.name}"/>
<zip destfile="${zip_dir}/${dir.name}.zip" basedir="${file_name}"/>
</target>
<target name="-wrapper-zipContentPackage">
<antcall target="zipContentPackage" inheritAll="true">
<param name="file_name" value="${basedir}" />
</antcall>
</target>
<target name="packageContent">
<delete dir="${zip_dir}"/>
<mkdir dir="${zip_dir}"/>
<subant genericantfile="${ant.file}" target="-zipContentPackage" inheritall="true">
<dirset dir="${content_dir}" includes="*" />
</subant>
</target>
Notes:
I used sagioto's code to illustrate
This isn't the most efficient solution
I ended up using foreach of antcontrib
<target name="init">
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.compile.classpath"/>
</target>
<target name="packageContent" depends="init">
<delete dir="${zip_dir}"/>
<mkdir dir="${zip_dir}"/>
<foreach target="zipContentPackage" param="file_name">
<path>
<dirset dir="${content_dir}" includes="*"/>
</path>
</foreach>
</target>
<target name="zipContentPackage">
<basename property="dir.name" file="${file_name}"/>
<echo message="Zipping folder: ${dir.name}"/>
<zip destfile="${zip_dir}/${dir.name}.zip" basedir="${file_name}"/>
</target>

How to run Sahi tests as part of a Hudson build?

In the absence of a Maven plugin for Sahi, what's the easiest way to run Sahi tests from Hudson?
You do have a tutorial for integrating Hudson with Sahi, but it is based on a free-style project, and a Ant task (as Pascal Thivent commented)
with zkdemo.xml and other Sahi ant tasks detailed here:
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="bids" default="runfftests">
<property environment="env"/>
<property name="sahi.home" value="${env.SAHI_HOME}" location="/mnt/sda4/Sahi/sahi/" />
<property name="user.data" value="${env.SAHI_USERDATA_DIR}" location="/mnt/sda4/Sahi/sahi/userdata" />
<property name="urlbase" value="http://www.google.com/"/>
<taskdef name="sahi" classname="net.sf.sahi.ant.RunSahiTask" classpath="${sahi.home}/lib/ant-sahi.jar"/>
<target name="runfftests">
<antcall target="startsahi"/>
<sleep seconds="4"/>
<sahi suite="${user.data}/scripts/my.suite"
browser="/usr/bin/firefox"
baseurl="${urlbase}"
sahihost="localhost"
sahiport="9999"
failureproperty="sahi.failed"
haltonfailure="false"
browserProcessName="firefox"
threads="3">
</sahi>
<sleep seconds="4"/>
<antcall target="stopsahi"/>
<sleep seconds="4"/>
<antcall target="failsahi"/>
</target>
<target name="failsahi" if="sahi.failed">
<fail message="Sahi tests failed!"/>
</target>
<target name="startsahi" description="start sahi proxy">
<java classname="net.sf.sahi.Proxy" fork="true" spawn="true" dir="${sahi.home}">
<!--<env key="MOZ_NO_REMOTE" value="1"/>-->
<classpath location="${sahi.home}/lib/sahi.jar">
<fileset dir="${sahi.home}/extlib" includes="**/*.jar"/>
</classpath>
<arg value="${sahi.home}" id="basePath"/>
<arg value="${user.data}" id="userdataPath"/>
</java>
</target>
<target name="stopsahi" description="stop sahi server">
<sahi stop="true" sahihost="localhost" sahiport="9999"/>
</target>
</project>
you can use maven Surefire plugin call sahi junit test case, then integrated with Jenkin server

In an ANT build.xml file, how can I iterate over the items in the ${env} variable?

This is in a Windows XP environment.
I'm trying to install and edit some files that have default settings. I want to update these settings use items from ${env}
Using foreach from ant-contrib, you could iterate over ${env} like:
<target name="run">
<foreach item="String" in="${env.CLASSPATH}" delim=";" property="x">
<echo message="${x}" />
</foreach>
</target>
I was able to do this with NAnt:
<target name="run">
<foreach item="String" in="${environment::get-variable('CLASSPATH')}" delim=";" property="x">
<echo message="${x}" />
</foreach>
</target>

Resources