triggersscheduled-tasksschedulingcruisecontrol.net

Force build in a time duration CCNet


I have an unwanted and sudden project related to Cruise Control on my plate few days back. It took me some time to understand what this Cruise Control actually is (I just knew Land Cruiser till now).

We have a bunch of projects that will build in a sequence in Cruise Control. We have configured everything for that. Now one part of my project is to run a utility after all the projects are built. As the projects will build in fixed sequence, I picked up the last project (say ProjectLast) to track. Following is the code sample to run the utility after the project build

<forcebuild>
    <project>MyUtility $(ccnet_branchlabel)</project>
    <integrationStatus>Success</integrationStatus>
    <enforcerName>ProjectLast $(ccnet_branchlabel)</enforcerName>
</forcebuild>

Now I want to run MyUtility in above code only in a fix duration of time like between 14.00 to 18.00. Is there a way to do this? Please help me to understand this. Thanks.

Here is what I want: The moment ProjectLast build finishes successfully and the time is between 14.00 to 18.00 then MyUtility should fire, otherwise not.


Solution

  • I think this should do roughly what you are after (untested). It should trigger a build when ProjectLast is at status Success (checking every 30 seconds), and the time is between 14:00 and 18:00 (checking the time every 60 seconds).

    <multiTrigger operator="And">
      <triggers>
    
        <projectTrigger serverUri="tcp://server:21234/CruiseManager.rem" project="ProjectLast">
          <triggerStatus>Success</triggerStatus>
          <innerTrigger type="intervalTrigger" seconds="30" buildCondition="ForceBuild" />
        </projectTrigger>
    
        <filterTrigger startTime="14:00" endTime="18:00">
          <trigger type="intervalTrigger" seconds="60" />
          <weekDays>
            <weekDay>Sunday</weekDay>
          </weekDays>
        </filterTrigger>
    
      </triggers>
    </multiTrigger>
    

    The documentation for cruisecontrol configuration (specifically triggers) should have enough explanation on all the possibilities.

    Edit:

    So at the moment, you have something (I imagine) which looks like this:

    <project name="ProjectLast">
    
        <tasks>
    
            <!-- some build tasks etc etc -->
    
            <forcebuild>
                <project>MyUtility $(ccnet_branchlabel)</project>
                <integrationStatus>Success</integrationStatus>
                <enforcerName>ProjectLast $(ccnet_branchlabel)</enforcerName>
            </forcebuild>
    
        </tasks>
    
    </project>
    
    <project name="MyUtility">
    
        <tasks>
    
            <!-- whatever it is "MyUtility" does goes here -->
    
        </tasks>
    
    </project>
    

    I am suggesting to change the configs to this:

    <project name="ProjectLast">
    
        <tasks>
    
            <!-- some build tasks etc etc -->
    
        </tasks>
    
    </project>
    
    <project name="MyUtility">
    
        <multiTrigger operator="And">
          <triggers>
    
            <!-- the url here will obviously need to change to match your server -->
            <projectTrigger serverUri="tcp://server:21234/CruiseManager.rem" project="ProjectLast">
              <triggerStatus>Success</triggerStatus>
              <innerTrigger type="intervalTrigger" seconds="30" buildCondition="ForceBuild" />
            </projectTrigger>
    
            <filterTrigger startTime="14:00" endTime="18:00">
              <trigger type="intervalTrigger" seconds="30" />
              <weekDays>
                <weekDay>Sunday</weekDay>
              </weekDays>
            </filterTrigger>
    
          </triggers>
        </multiTrigger>
    
        <tasks>
    
            <!-- whatever it is "MyUtility" does goes here -->
    
        </tasks>
    
    </project>
    

    Note here we have moved the decision of the project MyUtility whether to run or not into the MyUtility project, rather than in ProjectLast