Delphi – Sample cruisecontrol.net ccnet.config that works with msbuild and delphi XE

continuous integrationcruisecontrol.netdelphidelphi-xe

I asked some time ago for help getting continuous integration working in Delphi previously. One side-answer has partial incomplete (not working for me) information [here][2] for using cruisecontrol.

I have gotten Jenkins/Hudson working, and the easy part about it is that (with Delphi) the configuration is done purely through the Web browser. However with CruiseControl.net is much more difficult to set up.

I would like to see a sample ccnet.config that will build a hello-world delphi project (Project1.dproj) using MSBUILD, from CruiseControl, and auto-rebuild each time that the subversion (or mercurial) upstream sources are modified.

So far I have:

  • installed and got CruiseControl.net version 1.6.7981 and its running.
  • No valid projects in my ccnet.config

Here's my ccnet.config, originally I had <exec> and changed as suggested below to <msbuild>:

<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
        <!-- CRUISECONTROL.NET Server configuration -->
        <project name="Project1">
            <tasks>
                <msbuild>
                    <projectFile>project1.dproj</projectFile>
                </msbuild>
            </tasks>
        </project>
</cruisecontrol>

Update: I was originally unable to make it read c:\builds\ccnet.config from ccnet.exe but I found that I could run ccnet.exe (non-service mode) with a command line parameter and that got me around the problem finding my ccnet.config.

Best Answer

Here is a sample configuration block for a project that is rebuild at 05:00 if modification exists:

<!-- DelphiCodeToDoc Project -->
<project name="DelphiCodeToDoc" queue="Q1" queuePriority="1">
  <category>Delphi</category>
  <artifactDirectory>$(ArtifactBaseDir)\DelphiCodeToDoc</artifactDirectory>
  <workingDirectory>$(WorkingBaseDir)\DelphiCodeToDoc</workingDirectory>
  <triggers>
    <scheduleTrigger time="05:00" buildCondition="IfModificationExists" name="Scheduled" />
  </triggers>

  <!-- SVN implementation -->
  <sourcecontrol type="svn">
    <trunkUrl>http://dephicodetodoc.svn.sourceforge.net/svnroot/dephicodetodoc/trunk/DelphiCodeToDoc/</trunkUrl>
    <workingDirectory>$(WorkingBaseDir)\DelphiCodeToDoc</workingDirectory>
  </sourcecontrol>

  <!-- Build tasks to implement -->
  <tasks>

    <!-- Compile command-line application -->
    <msbuild>
      <executable>$(MSBuildPath)\MSBuild.exe</executable>
      <workingDirectory>$(WorkingBaseDir)\DelphiCodeToDoc\Source</workingDirectory>
      <projectFile>DCTD_cmd.dproj</projectFile>
      <buildArgs>/target:Build /p:Config=Debug</buildArgs>
      <timeout>900</timeout>
      <logger>$(MSBuildLogger)</logger>
    </msbuild>

  <!-- Publishing compiled results -->
  <publishers>
    <merge>
      <files>
        <file>$(ArtifactBaseDir)\DelphiCodeToDoc\buildlogs*.xml</file>
      </files>
    </merge>

  <!-- Statistics -->
    <xmllogger />
    <rss/>
    <statistics>
    </statistics>

  </publishers>
</project>

You can define variables $(MSBuildPath) in this way:

  <cb:define MSBuildPath="C:\WINDOWS\Microsoft.NET\Framework\v3.5" />

Or replace it directly with the real path.

Related Topic