Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Bug: Build Condition of a Configuration ignored on first scheduled run #4465

stang ·

Versions affected

Bug was observed in QuickBuild 12.0.9 and 12.0.27.

Repro steps:

Create a new child Configuration under any Configuration that has an empty master Step or a master Step that only runs dummy Steps that are safe to run anytime.

Specify the following:

Name=anything you want. For this example, I used "scheduleBuildConditionScriptReturnFalse".

Next Build Version=Use specified version=1.2345.0

Reason: We are using a value other than the default of 1.0.0 so that it will easier to spot in the server log.

Schedule=Cron schedule
Expression=0 * * * * ?
paused=false
Random Range=0

Build Condition=If specified script evaluates to true

groovy:
logger.info('Returning false for Build Condition');
return false;

Click Save.

Watch the clock and wait for the next minute to roll around.

Observed:

the new Configuration runs once.

Expected:

The new Configuration does not run.

Additional notes:

After this first-time run of the Configuration, the Build Condition is respected as expected and the Configuration does not continue to run every minute.
So this bug where the Build Condition is ignored appears to happen only the first time the Configuration's Schedule is met.

This bug appears to also happen if you use a Periodical Schedule, or if you use a different Build Condition, such as "If specified variable evaluates to true" and you select a Variable that has a value of "false".

Server Log

In my example above, the Server Log contains the following.
Note that I have no other scheduled jobs on this server that would start at 17:48:00, so the log messages at 17:48:00 below all pertain to the new Configuration I added.

2023-01-30 17:48:00,041 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Processing build request (configuration:root/Test/stang/scheduleTest/scheduleBuildConditionScriptReturnFalse, request id:d2c43cca-d411-4bb8-8cbb-9b3247cbaeb8)
2023-01-30 17:48:00,044 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Checking build condition on node (address: myquickbuildserver:1443, ip: 10.17.203.172)...
2023-01-30 17:48:00,053 [pool-2-thread-2440] INFO  com.pmease.quickbuild.CheckConditionJob - Taking repository snapshots...
2023-01-30 17:48:00,053 [pool-2-thread-2440] INFO  com.pmease.quickbuild.CheckConditionJob - Evaluating build condition...
2023-01-30 17:48:00,053 [pool-2-thread-2440] INFO  com.pmease.quickbuild.Context - Returning false for Build Condition
2023-01-30 17:48:00,167 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - New build version is calculated as '1.2345.0'.

2023-01-30 17:48:00,649 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'My Metrics'...
2023-01-30 17:48:00,649 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'Java NCSS'...
2023-01-30 17:48:00,649 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'SonarQube Report'...
2023-01-30 17:48:00,649 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'SCM Changes'...
2023-01-30 17:48:00,650 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'NCover Report'...
2023-01-30 17:48:00,650 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'Clover Report'...
2023-01-30 17:48:00,650 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'JUnit Report'...
2023-01-30 17:48:00,650 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'CPD Report'...
2023-01-30 17:48:00,650 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'MSTest Report'...
2023-01-30 17:48:00,650 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'TAP Report'...
2023-01-30 17:48:00,650 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'Bullseye Report'...
2023-01-30 17:48:00,650 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'Custom Statistics'...
2023-01-30 17:48:00,650 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'FindBugs Report'...
2023-01-30 17:48:00,650 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'JMeter Report'...
2023-01-30 17:48:00,650 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'Cobertura Report'...
2023-01-30 17:48:00,650 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'PMD Report'...
2023-01-30 17:48:00,651 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'TestNG Report'...
2023-01-30 17:48:00,651 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'Valgrind Report'...
2023-01-30 17:48:00,651 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'MBUnit Report'...
2023-01-30 17:48:00,651 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'CodeNarc Report'...
2023-01-30 17:48:00,651 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'Coverity Report'...
2023-01-30 17:48:00,651 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'CheckStyle Report'...
2023-01-30 17:48:00,651 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'Cppcheck Report'...
2023-01-30 17:48:00,651 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'Fxcop Report'...
2023-01-30 17:48:00,651 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'Jacoco Report'...
2023-01-30 17:48:00,651 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'NUnit Report'...
2023-01-30 17:48:00,651 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'Build Stats'...
2023-01-30 17:48:00,682 [pool-2-thread-2415] INFO  com.pmease.quickbuild.plugin.report.buildstats.StepStatisticsGenerator - Deleting step records of current build 35399
2023-01-30 17:48:00,698 [pool-2-thread-2415] INFO  com.pmease.quickbuild.plugin.report.engine.contribution.publisher.StatisticsReportPublisher - Finished collecting statistics data for report 'Build Stats' [configuration: 34053, build: 35399]
2023-01-30 17:48:00,698 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'EMMA Report'...
2023-01-30 17:48:00,698 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'Busted Report'...
2023-01-30 17:48:00,698 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Collecting statistics 'Boost Test'...
2023-01-30 17:48:00,699 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Populating configuration data...
2023-01-30 17:48:00,699 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Sending build notifications...
2023-01-30 17:48:00,731 [pool-2-thread-2415] INFO  com.pmease.quickbuild.DefaultBuildEngine - Build request has been processed.

The fact that the Server Log contains the following snippet:

2023-01-30 17:48:00,053 [pool-2-thread-2440] INFO  com.pmease.quickbuild.CheckConditionJob - Evaluating build condition...
2023-01-30 17:48:00,053 [pool-2-thread-2440] INFO  com.pmease.quickbuild.Context - Returning false for Build Condition

shows that it did in fact evaluate the Build Condition script, but ignored the result and ran the Configuration anyway.

The Build ID 35399 noted in the server log was the build ID of the Build of the new Configuration that unexpectedly ran.

  • replies 6
  • views 222
  • stars 0
robinshen ADMIN ·

This is expected behavior. The first build will always run serving as a base for change calculation for later builds in same configuration.

tomz ·

This seems like undesirable behavior. Would it be difficult to reverse it? In most instances that I can think of, you would want to always adhere to the condition of the script. If that is impossible or difficult for other reasons, what would be the best alternative for achieving the same thing?

robinshen ADMIN ·
drdt ·

Could you put the check in the pre-build or pre-queue step?

tomz ·

We could but it would be less elegant. We were in discussion of options, and this is just another type of option where we would have to write some specialized code that needs to disable multiple things (variable sets and promotions) when one place should suffice.

stang ·

Robin, thanks for the upcoming feature in 13.0.6.

drdt, thanks for the suggestion. Confirmed that returning false from a Pre-Queue Script prevents the first-time configuration run.

I just tested this Pre-Queue Script:

groovy:
logger.info('schedulePreQueueScriptReturnFalse returning false for Pre-Queue');
return false;

and it works as desired. The configuration did not run at any scheduled time, and the server log corroborated:

2023-02-01 11:49:00,016 [pool-2-thread-3661] INFO  com.pmease.quickbuild.Context - schedulePreQueueScriptReturnFalse returning false for Pre-Queue
2023-02-01 11:49:00,016 [pool-2-thread-3661] WARN  com.pmease.quickbuild.DefaultBuildEngine - Build request for 'root/Test/stang/scheduleTest/schedulePreQueueScriptReturnFalse' is ignored as pre-queue script evaluates to false.

The system setting to be added in 13.0.6 is still preferable though, because the Schedule and Build Condition are both on the General Setting page, whereas the Pre-Queue Script is on the Advanced Setting page. Using only the General Setting page would make things easier and faster to inspect and debug at a glance.