How do I create a ZIP file of my Cruise Control builds? - continuous-integration

I use CruiseControl.NET to automatically build my .NET 3.5 web applications, which works a treat. However, is there any way to automatically create a ZIP file of these builds, and put the ZIP's into a separate directory?
I have seen this is possible using NAnt but cannot find an example of how to get this working.
Can anyone offer help/examples?

I've just added such a Nant task to our CC machine.
See http://nant.sourceforge.net/release/latest/help/tasks/zip.html
Note when initially viewing the zip archive, it may appear as if all the files are at the same level, i.e no folders, but actually they folders are preserved.
Notice how you can exclude file types or folders.
You could take the approach of only including the file types you want and excluding the rest.
First define properties for where the source files are allcode.dir and the name and location of the zip file sourcebackup.zip
Now here is the nant task
<zip zipfile="${sourcebackup.zip}" includeemptydirs="true" verbose="true">
<fileset basedir="${allcode.dir}">
<include name="**/*" />
<exclude name="**/_resharper*/**" />
<exclude name="**/build/**" />
<exclude name="**/obj/**" />
<exclude name="**/bin/**" />
<exclude name="**/*.dll" />
<exclude name="**/*.scc" />
<exclude name="**/*.log" />
<exclude name="**/*.vssscc" />
<exclude name="**/*.suo" />
<exclude name="**/*.user" />
<exclude name="**/*.pdb" />
<exclude name="**/*.cache" />
<exclude name="**/*.vspscc" />
<exclude name="**/*.msi" />
<exclude name="**/*.irs" />
<exclude name="**/*.exe" />
</fileset>
<echo message="########## Zipped##########" />
Call this from your cc build like any other nant task.
We find it best if each CC project calls a single task if possible, then you only have to change the nant script, and you can run the nant script on your local machine.
Eg in the project block, we have the single target "build", which as part of its work calls ZipSource
<targetList>
<target>Build</target>
</targetList>
We use the above for a BizTalk project.
Enjoy.

If you're using Nant, then doesn't the Zip task work for you?

We are zipping the sources of a CruiseControl.NET project
but we are using ant
<target name="zipProject">
<mkdir dir="output"/>
<zip destfile="output\sources.zip" basedir="C:\project\src" />
</target>
i don't know about nant but i would expect it to be similar

#David: The NAnt Zip task is what I'm after, yes, but I'm asking how to integrate it as part of an automatic CruiseControl.NET build. If you take a look at the NAnt documentation for the cruise control config it doesn't make it clear if I can run an NAnt task from inside the <tasks> XML node in my CruiseControl config - it only says that it can be part of a <schedule>.
I have found a few examples of setting up your CruiseControl config and a few examples of NAnt tasks but nothing that integrates the two: specifically, zipping up a CruiseControl build.
If anyone has some sample XML of their CruiseControl config, hooking up to an NAnt zip task, post samples here.
Cheers.

Related

How to install updates on Progress-4GL programs

Good afternoon,
In my company, we are regularly doing updates on customers' systems, all Progress-4GL technology. Currently we are doing all this manually, and I'd like to automate this.
The following actions are needed:
Take a dump (*.df) of the current database
Upload modifications to the database (*.df files)
compile *.w and *.p files.
Is there a tool that does all that (together with zipping/unzipping *.w, *.p and *.i files), or do I need to create such a tool myself?
In the latter case, what are the commandline commands for the mentioned actions:
Take a dump (*.df) of the current database
Upload modifications to the database (*.df files)
compile *.w and *.p files.
If you're familiar with ANT, the take a look at the PCT plugin for ANT:
https://github.com/Riverside-Software/pct
This makes is easy to create a delta.df file between the "new" full DF and the current database, e.g.:
<PCTDumpIncremental destFile="temp/delta.df" dlcHome="${dlc}"
debugLevel="2" activeIndexes="0" removeEmptyDFFile="true" msgBufferSize="${Mm}" >
<SourceDB dbname="temp/ref-SmartDB" singleUser="true" />
<TargetDB dbname="${smartdb}" dbDir="${smartdbdir}" singleUser="${smartdbsingleuser}"/>
</PCTDumpIncremental>
and then load the delta.df into the current application DB:
<PCTLoadSchema srcFile="temp/delta.df" dlcHome="${dlc}" onlineChanges="true" callbackClass="rssw.pct.AbstractLoadCallback" msgBufferSize="${Mm}" commitWhenErrors="false">
<DBConnectionSet refid="smartdbset" />
</PCTLoadSchema>
and then compile the application:
<PCTCompile destDir="${installroot}" graphicalMode="true" dlcHome="${dlc}"
md5="true" minSize="false" cpinternal="${cpinternal}" cpColl="${cpcoll}" cpstream="${cpstream}"
compileUnderscore="true" inputchars="32000" baseDir="${installroot}"
token="4000" progPerc="10" assemblies="${assemblies}">
<fileset dir="${installroot}" casesensitive="false">
<include name="Ccs/**/*.cls"/>
<include name="Consultingwerk/**/*.cls"/>
<include name="Consultingwerk/**/*.p"/>
<include name="Consultingwerk/**/*.w"/>
<include name="Setup/**/*.p"/>
<include name="src/**/*.p"/>
</fileset>
<propath>
<pathelement path="${installroot}/." />
<pathelement path="${installroot}/src" />
<pathelement path="${installroot}/Consultingwerk/Studio/ProdictDumpHack/src" />
<pathelement path="${dlc}/gui/netlib/OpenEdge.Net.pl" />
</propath>
<DBConnectionSet refid="smartdbset" />
</PCTCompile>
ANT and PCT are included in OpenEdge from 11.7 on. Since you're on 11.6, you'll have to bring your own ANT and PCT.

How to scan code recursively in sonarqube

I have some code in different folders like folder a, folder b,folder c....and all these three folders are in folder name "sonar". if I want to scan all these folders at a time using sonarqube how can I do it. will it be fine if I keep sonar-project.properties file in folder sonar? or do I need to keep sonar-project.properties in all the folders like in folder a, folder b, and folder c individiually
Usually properties should be there for every folder for making analysis on every folder.
You can also try the following approach if it suits your needs and if it is not a big learning curve:
Prerequisites:
ANT Knowledge
Sonar API
Advantages:
1. Single/Central approach for every code analysis
2. Can avoid sonar.properties for every project/source folder
In this approach, write an ANT script that accepts dynamic parameters
Sample:
<target name="setsonarproperties" description="Setting the sonar properties">
<property name="sonar.projectVersion" value="${projectVersion}" />
<property name="sonar.projectKey" value="${targetProduct}_${projectVersion}" />
<property name="sonar.projectName" value="${targetProduct}" />
<property name="sonar.host.url" value="${hostUrl}" />
<property name="sonar.login" value="${hostUserName}" />
<property name="sonar.password" value="${hostPassword}" />
<loadfile property="textFile" srcfile="${buildOrder}" />
<for param="line" list="${textFile}" delimiter="${line.separator}">
<sequential>
<echo message="#{line}" />
<copy todir="${sourcePath}/sonarsources/#{line}">
<fileset dir="${sourcePath}/#{line}">
</fileset>
</copy>
</sequential>
</for>
</target>
Next also set the sonar user name and password details:
Run analyser:
<target name="sonar" depends="setsonarproperties" description="executing sonar">
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<!-- Update the following line, or put the "sonar-ant-task-*.jar" file
in your "$HOME/.ant/lib" folder -->
</taskdef>
<sonar:sonar />
</target>

Ant Target to Expand Archives of Dependency

I have an Ant/Ivy build process that I am trying to improve. I need to resolve dependencies and then extract them to a particular folder.
The dependencies resolve to a $(build_root)/dependency/downloads/[configuration]/[artifactId]/[version]/ location and this works fine. I end up with a .pom and a .tar.bz2 file in that location.
What I would like to do is have a bit more control over the extraction of the dependency's .tar.bz2 to a directory. We're basically trying to prevent conflicts for a dependency's lib and inc by controlling how and where the extraction of the .tar.bz2 output occurs.
We currently do this by resolving all the dependencies, and then having a target to expand the archives blindly.
Our resolve step looks like:
<target name="resolve">
<ivy:retrieve pattern="${dependency.dir}/[conf]/[artifact]/[artifact]-[revision].[ext]" conf="*" />
<condition property="archive.dir.present">
<resourceexists>
<file file="${dependency.dir}"/>
</resourceexists>
</condition>
<antcall if:set="archive.dir.present" target="expand-archives"/>
</target>
Note the separate call to the "expand-archives" target, which looks like:
<target name="expand-archives" description="Expand your Dependency Archives!">
<for param="file">
<path>
<fileset dir="${dependency.dir}" includes="**/*.tar.bz2"/>
</path>
<sequential>
<bunzip2 src="#{file}" dest="${dependency.dir}" />
</sequential>
</for>
<!-- Follow the bunzip2 by the tar command to extract the tarball -->
<for param="file">
<path>
<fileset dir="${dependency.dir}" includes="**/*.tar"/>
</path>
<sequential>
<echo message="Processing: #{file}"/>
<exec executable="tar" failonerror="true">
<arg value="-C"/>
<arg value="${dependency.dir}"/>
<arg value="-xvf"/>
<arg value="#{file}"/>
</exec>
</sequential>
</for>
</target>
What I would love to have is the dest="${dependency.dir} have a dependency's artifactID appended to it.
Is there any way to get the [artifact] information from the retrieve and pass that into the expand-archives target?
Thank you
If you have dependencies on files located within archives, perhaps you should investigate the packager resolver in ivy.
This resolver is designed to download + extract archives and then use an ANT snippet to decide which files within you want to depend on. At first glance complicated, but once understood very powerful.
The following example shows how to depend on a jar, contained inside a downloadable ".tar.gz" archive:
ivy dependency on external JAR

Izpack installer for non-java applications

Can the Izpack installer be used to install a non-java application?
Thanks,
Abdulfattah.
It should be. It will bundle everything together in a jar file. For the pack tag of the install file, call the following:
<pack name="PROJECTPACKNAME" required="yes" preselected="yes"
installGroups="New Application">
<description>PROJECT install</description>
<file src="#{DIRECTORYNAME.dir}" targetdir="$INSTALL_PATH" />
</pack>
For DIRECTORYNAME, you have to declare a property in your build file, ie:
<property name="DIRECTORYNAME.dir" value="/apps/MyProjectName"/>
then have a target in the build file:
<target name="SftWreBundle" depends="init" description="build the software bundle">
<taskdef name="izpack" classpath="${izpack.dir}/lib/standalone-compiler.jar" classname="com.izforge.izpack.ant.IzPackTask" />
<izpack input="install.xml" output="${dist}/${product.short.name}-${product.version}-install.jar"
installerType="standard" inheritAll="true"
basedir="${basedir}" compression="deflate" compressionlevel="9" />
</target>
You may want to clean your working directory before running this target.

is it possible to make nant run a publish on web application project

is it possible to make nant run a publish on mvc project or a good old web application project
and after the publish make nant FTP the files to the web server
UPDATE: found the solution to the ftp problem
Nant ftp task thanks Paco
what i mean by publich
is there a command line application or nant task that can public like visual studio publish...
The visual studio publish command rebuilds your solution and then copies the files in the solution directory to a new directory. I use the following target to do almost the same:
<target name="copyToPublish">
<delete dir="${dir.publish}" />
<mkdir dir="${dir.publish}" />
<mkdir dir="${dir.publish}\wwwroot"/>
<copy todir="${dir.publish}\wwwroot" includeemptydirs="false">
<fileset basedir="${website.dir}">
<exclude name="**/*.cs"/>
<exclude name="**/*.pdb"/>
<exclude name="**/*.csproj*"/>
<exclude name="**/obj/**"/>
<include name="**/*.*"/>
</fileset>
</copy>
<mkdir dir="${dir.publish}\database"/>
<copy todir="${dir.publish}\database" includeemptydirs="false">
<fileset basedir="${dir.databasescripts}">
<include name="**/*.sql" />
</fileset>
</copy>
<xmlpoke
file="${dir.publish}\wwwroot\Web.config"
xpath="/configuration/system.web/compilation/#debug"
value="false" />
<xmlpoke
file="${dir.publish}\wwwroot\Web.config"
xpath="/configuration/system.web/trace/#enabled"
value="false" />
<move file="${dir.publish}\wwwroot\Web.config" tofile="${dir.publish}\wwwroot\Release.config" overwrite="true" />
<delete file="${dir.publish}\wwwroot\Web.config" />
</target>
Before this target you have to run the normal build procedure of course.
There is a Ftp Task for nant.
Beside that, you have to create a script that copies the files and directories you need and the config files. I don't do it automatically, because I want to have control over database update scripts and changes in web.config.

Resources