views:

339

answers:

4

For example I have three tasks: task1, task2, task3. How to write a CruiseControl.NET configuration file that runs task3 but only after task2 ends with success?

+2  A: 

I'd suggest you do that inside your NAnt or MSBuild task instead, and move it out of your CruiseControl.NET configuration.

What do your tasks do? Any reason you can't move them inside your NAnt or MSBuild script?

Wim Hollebrandse
A: 

I would recommend a script file (bat, PowerShell) where you run the tasks and check for success.

vladhorby
+4  A: 

Depending on what you are trying to accomplish, this can be done pretty easily in 2 ways:

A) CruiseControl.NET supports what is referred to as projectTriggers:

In order to use this approach, each task needs to be isolated into their own project configuration. Basically, the task3 project monitors the build status of the task2 project. When the task2 project successfully completes, the task3 project triggers a build. To setup a projectTrigger, edit your task3 project definition in ccnet.config and create a trigger block as follows:

<triggers>
  <multiTrigger>
    <triggers>
      <intervalTrigger seconds="30" />
      <projectTrigger project="task2">
        <triggerStatus>Success</triggerStatus>
      </projectTrigger>
    </triggers>
  </multiTrigger>
</triggers>


B) Setup the order of your tasks using Nant targets instead:

As pointed out by Wim, you may want to consider breaking the tasks out into Nant targets instead of trying to do it in the ccnet.config. Personally, I find this approach more comfortable only because I know Nant is good at doing just this sort of thing.

Saul Dolgin
+4  A: 

CruiseControl.NET v1.5 enhances the execution of tasks using their new Sequential and Parallel tasks...

http://confluence.public.thoughtworks.org/display/CCNET/Sequential+Task

<sequential continueOnFailure="false">
  <description>Example of how to run multiple tasks in sequence.</description>
  <tasks>
    <!-- Tasks defined here -->
  </tasks>
</sequential>
George
+1 I did not know this feature was added. Nice answer as long as @dario doesn't mind using the 1.5 CTP release for now
Saul Dolgin
Yes, that's the caveat. It's still a CTP. I'd test it first before migrating over to the new version.
George
Great to hear about that, but still using 1.4 ver.
dario