TeamCity On-Premises 2024.12 Help

Cron Expressions

TeamCity allows you to flexibly schedule regular operations using the cron format. Currently, cron-like expressions are supported for schedule triggers and server clean-up.

TeamCity uses Quartz for working with cron expressions. See the examples below or consider using the CronMaker utility to generate expressions based on the Quartz cron format.

Cron format in TeamCity

Cron expressions comprise six fields and one optional field separated with a white space. The fields are respectively described as follows:

Field Name

Values

Special Characters

Seconds

0\-59

, \- * /

Minutes

0\-59

, \- * /

Hours

0\-23

, \- * /

Day\-of\-month

1\-31

, \- * ? / L W

Month

1\-12 of JAN\-DEC

, \- * /

Day\-of\-week

1\-7 or SUN\-SAT

, \- * ? / L #

Year (Optional)

empty, 1970\-2099

, \- * /

For the description of special characters, refer to Quartz CronTrigger Tutorial.

Examples

Schedule

Cron Expression

Each 2 hours at :30

0 30 0/2 * * ? *

Every day at 11:45PM

0 45 23 * * ? *

Every Sunday at 1:00AM

0 0 1 ? * 1 *

Every last day of month at 10:00AM and 10:00PM

0 0 10,22 L * ? *

Every 2 hours on weekdays, but not on weekends

0 0 0/2 ? * 2-6 *

Where the cron expressions in this table have the following format:

Sec Min Hour Day-of-month Month Day-of-week Year

See also other examples.

Kotlin DSL

Using Kotlin DSL to configure a schedule trigger with the 0 0 0/2 ? * 2-6 * cron expression:

object Build : BuildType({ triggers { schedule { schedulingPolicy = cron { seconds = "0" minutes = "0" hours = "0/2" dayOfMonth = "?" month = "*" dayOfWeek = "2-6" year = "*" } triggerBuild = always() } } })
Last modified: 18 September 2024