CCnet queue priorities not sequencing - cruisecontrol.net

I am setting up a nightly build using ccnet 1.6 to run projects sequentially and exclusively, but however I set up the queues when the build is triggered the projects do not start in the expected order as defined by the queue priority. The config below randomly starts queues 1, 2, 3 or 4 first then completes the remaining projects in the defined sequence order (ie 2, 1, 3, 4 or 3, 1, 2, 4 etc). I've tried xlmns 1.6 and 1.5 with same results. I can't see why this is not working, am I missing something?
Thanks
<cb:define name="Common">
<webURL>http://hostname/ccnet/server/local/project\$(CCProjectName)\ViewLatestBuildReport.aspx</webURL>
<workingDirectory>D:\source\$(ProjectName)</workingDirectory>
<sourcecontrol type="svn"/>
<modificationDelaySeconds>60</modificationDelaySeconds>
<triggers>
<scheduleTrigger time="11:05" buildCondition="ForceBuild "/>
</triggers>
<state type="state" directory="C:\Program Files\CruiseControl.NET\server" />
</cb:define>
<cb:define name="BuildProject">
<project name="$(CCProjectName)" queue="SequentialQueue" queuePriority="$(QueuePriority)">
<cb:Common />
<tasks>
<exec>
<executable>$(ANT_HOME)\bin\ant.bat</executable>
<buildArgs>-logger org.apache.tools.ant.XmlLogger -logfile build_log.xml -f build\$(ProjectName).xml</buildArgs>
</exec>
</tasks>
<publishers>
<merge>
<files>
<file>D:\source\$(ProjectName)\build\*.xml</file>
</files>
</merge>
<xmllogger />
</publishers>
</project>
</cb:define>
<cb:BuildProject CCProjectName="API" ProjectName="api" QueuePriority="1" />
<cb:BuildProject CCProjectName="Ack" ProjectName="acknowledgement" QueuePriority="2" />
<cb:BuildProject CCProjectName="Error" ProjectName="error" QueuePriority="3" />
<cb:BuildProject CCProjectName="Monitoring" ProjectName="monitoring" QueuePriority="4" />

I'm guessing this is a bug in CruiseControl.Net, your scenario (variable priority projects in one queue triggered by the same schedule trigger) is not a common one. You should file a bug on cruisecontrolnet.org.
A more usual solution for this kind of setup is having the projects trigger each other using <projectTrigger/>, which also results in a sequential build. You'll probably want to change the triggerStatus parameter so that a failed build does not stop the chain.

Related

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>

Multi Projects with CCNET

I have GIT repo as below,
\main
\Module A
\Module B
\Shared
When i make a change on Module B, CCNET will make a build from Module A and then Module B,
I dont want CCNET to do this way.It will take a lot of time.
I just want ccnet build only changes on Module B.
Somebody please help me :
My 1 project in CCNET Config:
enter code here
<project name="Dashboard 5.0" queue="Dashboard_01" queuePriority="01" category="01">
<artifactDirectory>&pathToArtifactsDirectory;Dashboard 5.0\</artifactDirectory>
&workingDirectory;
<webURL>http://&buildServerAddress;/ccnet/server/&buildServerName;/project/Dashboard 5.0/ViewLatestBuildReport.aspx</webURL>
&modificationDelaySeconds;
<triggers>
<intervalTrigger seconds='30' buildCondition='IfModificationExists'/>
<scheduleTrigger time='03:00' buildCondition='ForceBuild' name='Scheduled'/>
<scheduleTrigger time='11:00' buildCondition='ForceBuild' name='Scheduled'/>
</triggers>
<state type="state" directory="&pathToStatesDirectory;Dashboard 5.0\" />
<sourcecontrol type="git">
<repository>&gitAddress;</repository>
<branch>master</branch>
<autoGetSource>true</autoGetSource>
<fetchSubmodules>false</fetchSubmodules>
<executable>C:\Program Files (x86)\Git\cmd\git.exe</executable>
<commitBuildModifications>false</commitBuildModifications>
<commitUntrackedFiles>false</commitUntrackedFiles>
<timeout>3000000</timeout>
</sourcecontrol>
<tasks>
<nant>
<executable>&pathToNantFile;</executable>
<baseDirectory>&pathToBuildScriptsDirectory;Dashboard 5.0\</baseDirectory>
<buildArgs>-D:projects_to_build=dashboard_framework</buildArgs>
<buildFile>cruise.build</buildFile>
<targetList>
<target>automate</target>
</targetList>
<buildTimeoutSeconds>3000</buildTimeoutSeconds>
</nant>
</tasks>
<publishers>
<merge>
<files>
<file>&pathDB5MainCheckoutDirectory;framework\build\test-reports\*Test.dll-results.xml</file>
<file>&pathDB5MainCheckoutDirectory;framework\build\test-reports\Test*.dll-results.xml</file>
<file>&pathDB5MainCheckoutDirectory;framework\build\test-reports\simian.xml</file>
</files>
</merge>
<xmllogger />
</publishers>
Any check in for Module A or Module B will cause the project node to start either way. What you are looking for is similar to what subversion update command on a sub folder does and Git is not intended to be this way. An alternative you can create a separate repository for each module. The build script or Nant task would have to be separated as well.
In Git, if you have several directories that are always checked out independently, then these are really two different projects and should live in two different repositories. You can merge them back together at a later point using Git Submodules

How do I configure two different triggers for a project in CruiseControl.Net?

I would like to know if its possible to create two triggers, one on a filesystem and another for an svn checkout in the same config file.
I have tried out the following:
a) have put both the triggers and their respective filesystem, svn definitions along with tasks in the same file,
Results in error: It says unused node deteted
eg:
<trigggers>
<intervalTrigger seconds="100" buildCondition="ForceBuild"/>
<intervalTrigger seconds="300" buildCondition="IfModificationExists"/>
</triggers>
<sourcecontrol type="filesystem">
<repositoryRoot>...</repositoryRoot>
</sourcecontrol>
<sourcecontrol type="svn">
<trunkUrl>....</trunkUrl>
<workingDirectory>...</workingDirectory>
<executable>...\SVN.exe</executable>
<username/>..<password/>
</sourcecontrol>
<tasks>
<!-- To be carried out if either of the two triggers happen -->
</tasks>
b) have created different scopes for each of the trigger bound with respective filesystem/svn and tasks, also ends up with unused node detected error.
<cb:define first_trigger_and source _and_tasks>
<triggers>
<intervalTrigger seconds="300" buildCondition="ForceBuild"/>
</triggers>
<sourcecontrol type="filesystem">
<repositoryRoot>...</repositoryRoot>
</sourcecontrol>
<tasks>
<!--To be carried out when first trigger happens -->
</tasks>
</cb:define>
<!-- And then I call the trigger this way -->
<cb:first_trigger_and source _and_tasks>
Neither of those solution works.
Multiple triggers can be specified inside the <triggers> block, but that is not why CruiseControl.Net is complaining when it's processing your configuration.
It seems to me that you want a single trigger, but two separate source control entries. The <triggers> entries specify when CruiseControl.Net should wake up and check the project state. You can't specify multiple <sourcecontrol> elements in a <project> block. To actually rebuild project on both (remote) svn changes and local filesystem changes, you should use <sourcecontrol type="multi"> with a standard trigger:
<triggers>
<intervalTrigger seconds="30" />
</triggers>
<sourcecontrol type="multi">
<sourceControls>
<filesystem>
<repositoryRoot>...</repositoryRoot>
</filesystem>
<svn>
<trunkUrl>....</trunkUrl>
<workingDirectory>...</workingDirectory>
<executable>...\SVN.exe</executable>
<username/>..<password/>
</svn>
</sourceControls>
</sourcecontrol>
<tasks>
<!-- To be executed if either of the two source control providers report changes -->
</tasks>

How to search for a string in files with Ant (make sure certain string isn't found in source files)

I'd like to search for a string within my source files with Ant. (I'd like my build to fail in case certain string is found within my source files).
So, I should be able to recursively search for a certain string within a file set.
I already found that I can use loadfile task to check whether a string pattern is found within one file. But that seems to be working & sensible only with a single file.
On the other hand, replace task would provide recursively search-and-replace. I guess I could do that before build and replace my string with something that would break the build but I wonder if there is some cleaner solution?
br, Touko
You might consider using fileset selectors to do this. Selectors allow you to choose files based on content, size, editability and so on. You can combine selectors with name-based includes and excludes, or patternsets.
Below is an example. The second fileset is derived from the first, with a selector that simply matches on file content. For more sophisticated matching there is the containsregexp selector. The result is a fileset containing only files matching the string. A fail task with a resourcecount condition is then used to fail the build, unless that fileset is empty.
<property name="src.dir" value="src" />
<property name="search.string" value="BAD" />
<fileset id="existing" dir="${src.dir}">
<patternset id="files">
<!-- includes/excludes for your source here -->
</patternset>
</fileset>
<fileset id="matches" dir="${src.dir}">
<patternset refid="files" />
<contains text="${search.string}" />
</fileset>
<fail message="Found '${search.string}' in one or more files in '${src.dir}'">
<condition>
<resourcecount when="greater" count="0" refid="matches" />
</condition>
</fail>
(Old answer): If adjusting or reusing filesets might be problematic, here's an illustration of a relatively simple alternative.
The idea is to make a copy of the files,
then replace the string you wish to search for
with some flag value in the copied files.
This will update the last modified time on any matching file.
The uptodate task can then be used to look for affected files.
Finally, unless no files matched, you can fail the build.
<property name="src.dir" value="src" />
<property name="work.dir" value="work" />
<property name="search.string" value="BAD" />
<delete dir="${work.dir}" />
<mkdir dir="${work.dir}" />
<fileset dir="${src.dir}" id="src.files">
<include name="*.txt" />
</fileset>
<copy todir="${work.dir}" preservelastmodified="true">
<fileset refid="src.files" />
</copy>
<fileset dir="${work.dir}" id="work.files">
<include name="*.txt" />
</fileset>
<replaceregexp match="${search.string}"
replace="FOUND_${search.string}">
<fileset refid="work.files" />
</replaceregexp>
<uptodate property="files.clean">
<srcfiles refid="work.files" />
<regexpmapper from="(.*)" to="${basedir}/${src.dir}/\1" />
</uptodate>
<fail message="Found '${search.string}' in one or more files in dir '${src.dir}'"
unless="files.clean" />
This was very helpful as a start, but I have a list of strings which should be checked in a fileset.
My current code sofar is:
<property name="search4" value="XYZ"/>
<fileset id="existing" dir="../src">
<patternset id="files">
<include name="content/**/*.txt"/>
</patternset>
</fileset>
<resourcecount property="count">
<fileset id="matches" dir="../src">
<patternset refid="files" />
<contains text="${search4}" />
</fileset>
</resourcecount>
<echo message="Found '${search4}' in files : '${count}'"/>
That works well, but how to expand that so the ${search4} is read from a list. Actually the list can be read from a file containing each search item is on a separate line.
Slightly more concise variation on the first part of #martinclayton's answer:
<property name="log.dir" value="logs" />
<property name="fail.string" value=" FAILED " />
<fileset id="build.failures" dir="${log.dir}" includes="*.log">
<contains text="${fail.string}"/>
</fileset>
<fail status="1" message="One or more failures detected">
<condition>
<resourcecount when="greater" count="0" refid="build.failures" />
</condition>
</fail>

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