Behavior of ScheduleTrigger on invalid weekDays

Added by Hwee Miin Koh about 4 years ago

Example: Two triggers were configured,
trigger 1 is an interval trigger which fire an incremental build when modification exists;
trigger 2 is a schedule trigger which force a full rebuild at 23:30 every Monday night.
If somehow the interval trigger fire a build at 23:29 at Monday night, and the build completed at 01:00 at Tuesday morning, the schedule trigger will not fire until next Monday. Thus we won't have full rebuild for this week.

I believe the reason is at ScheduleTrigger.cs, line 238
@
public IntegrationRequest Fire() {
DateTime now = dtProvider.Now;
if (now > NextBuild && IsValidWeekDay(now.DayOfWeek)) {
triggered = true;
return new IntegrationRequest(BuildCondition, Name, null);
}
return null;
}
@

Shouldn't it be checking IsValidWeekDay(NextBuild.DayOfWeek) instead of IsValidWeekDay(now.DayOfWeek) to ensure the schedule trigger fires at least once, even if it misses the day?
Is this a bug or is it a design decision?

Thanks.


Replies (4)

RE: Behavior of ScheduleTrigger on invalid weekDays - Added by Robert Flum about 4 years ago

Hi Koh,

You can get the effect you want by using a filterTrigger to prevent the incremental build
from happening during the time your full rebuild is scheduled.
Here's an example:

    <triggers>
    <multiTrigger operator="And">
      <triggers>
        <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
        <!--  Prevent an incremental build from starting when it would               -->
        <!--  interfere with the scheduled build.                                    -->
        <!--  The startTime should precede the scheduled full rebuild startTime by   -->
        <!--  enough time to allow an incremental build to finish before the    -->
        <!--  full build starts.                                                        -->
        <!--  The endTime should allow enough time after the startTime to complete    -->
        <!--  a full build.                                                        -->
        <!--  When this filter is not preventing a build, it will check for modifications  -->
        <!--  every 10 minutes, Monday through Friday.                                  -->
        <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
        <filterTrigger startTime="23:30" endTime="15:30">
          <trigger type="intervalTrigger" seconds="600" />
          <weekDays>
            <weekDay>Monday</weekDay>
            <weekDay>Tuesday</weekDay>
            <weekDay>Wednesday</weekDay>
            <weekDay>Thursay</weekDay>
            <weekDay>Friday</weekDay>
          </weekDays>
        </filterTrigger>

        <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
        <!-- Force a full rebuild at 23:30 every Monday night.                             -->
        <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
        <scheduleTrigger time="23:30" name="Scheduled" buildCondition="ForceBuild">
          <weekDays>
            <weekDay>Monday</weekDay>
          </weekDays>
        </scheduleTrigger>
      </triggers>
    </multiTrigger>
    </triggers>
let me know if this doesn't work for you, Rob

RE: Behavior of ScheduleTrigger on invalid weekDays - Added by Hwee Miin Koh about 4 years ago

Thanks for the suggestion and sorry for late reply.

I do notice this workaround, but it is base on assumption we know exactly how long it take to complete the incremental build. As project grows bigger and time to complete incremental build increase, we will need to adjust this timing as well (estimation of timing can be complicated when distributed build system is involve, and multiple builds are trigger together), and as the timing increase it means we get less incremental build.

I knows this is not a major issue, but would like to know whether blocked schedule trigger won't fire to catch-up the missed build on invalid weekday is a bug or a design decision, since if it is a bug the fix can be quite easy?

RE: Behavior of ScheduleTrigger on invalid weekDays - Added by Robert Flum about 4 years ago

Hi Miin,

Maybe this will work:
Use the Queue Configuration Element.

Option 1: The following example shows how to configure a queue so that force build requests will remove
existing non-forced requests from the interval trigger and re-add the force build request.
This removes the interval (non forced) builds and add the forced builds according to the queue priority setting.

<cruisecontrol>
<queue name="Q1" duplicates="ApplyForceBuildsReAdd" />
<project name="MyFirstProject" queue="Q1" queuePriority="1">
<otherProjectSettings />
</project>
</cruisecontrol>

Option 2: The following example shows how to configure a queue so that force build requests will remove
existing non-forced requests from the interval trigger and re-add the force build request at the top of the queue.

<cruisecontrol>
<queue name="Q1" duplicates="ApplyForceBuildsReAddTop" />
<project name="MyFirstProject" queue="Q1" queuePriority="1">
<otherProjectSettings />
</project>
</cruisecontrol>

This probably won't do what you need if the interval build is already running.
Another idea that just occurred to me is to create two projects running on different queues, 
and building the same code.
One of the projects would be triggered with your interval trigger and the other would be triggered
with your schedule trigger.
If the interval-triggered build started late Monday, it would not prevent the scheduled build
from starting at 23:30, because it's in a different queue.
The two builds would run at the same time, but I don't think that would be a problem technically.
You would have to define two different build areas so the scheduled build wouldn't overwrite
the interval build's files. If you check out version files to increment them, you would have
to coordinate the check-ins. You would need to make sure any logfile names weren't the same.
If you publish the executables after the build, or the installers, you would have to make sure
the destination for those executables or installers was different from the other build's.
Rob

RE: Behavior of ScheduleTrigger on invalid weekDays - Added by Hwee Miin Koh about 4 years ago

Thanks for the suggestion, but as you already mentioned, both of them are not elegant solutions:

This probably won't do what you need if the interval build is already running.

.....You would have to define two different build areas so the scheduled build wouldn't overwrite 
the interval build's files.  If you check out version....

Again, thanks for your time anyway.

(1-4/4)