Scheduled job builds are not triggering on time

Article ID:115003237887
2 minute readKnowledge base

Issue

  • Having set Build Triggers as Build Periodically at a specific time in the job configuration, Jenkins System triggers builds on a different time.

As an example:

On the Job Configuration

job config

On the Job Build History

job build history

Environment

  • Jenkins

  • CloudBees Jenkins Enterprise

Resolution

Ensure that Jenkins instance and users are aligned into the same Timezone.

In the case they are not aligned, you can edit it:

  • At Jenkins Server level as explained in Change Time Zone. For instances with users working across different Time Zones, the recommendation would be to set it to UTC.

  • At Job level a Timezone ID can be specified in the cron tab (TZ=<Timezone ID>). It overrides the Server time zone if it was in some other. For instance:

TZ=America/Chicago
00 19 * * *
To list available timezones ids in Jenkins, run the following script into <JENKINS_SERVER>/script
def timezones = TimeZone.getAvailableIDs()
for (i in timezones){
  println i

}

Further Troubleshooting

It is possible that a plugin may be adversely affecting the cron scheduler. To check for this, create a custom logger for the class hudson.triggers.Trigger with the log level set to FINEST.

logger

Allow the logger to capture several minutes of data. With each new invocation of the Cron scheduler, you will see a Cron#doRun entry.

2018-12-11 03:29:36.171+0000 [id=58]    FINE    hudson.triggers.Trigger$Cron#doRun: cron checking 12/8/18 9:38 PM

In the above entry, the cron scheduler is checking 9:38 PM of December 8th when the actual clock time of the server is 3:29 December 11.

If the time reported in cron checking does not match the server time, you have confirmation that the cron scheduler is not keeping up with the system clock and this would result in scheduled jobs triggering eratically or most likely not at all.

The cause of this has often been pull request plugins (BitBucket Pull Request, Stash Pull Request). See Stash pullrequest builder plugin makes scheduled job builds are not triggering on time.

Be sure to delete or disable the custom logger once the data has been collected as this level will have performance overhead.