We are thrilled to announce a major enhancement to Bitrise’s scheduling capabilities: the introduction of Cron-Based Build Scheduling! This new feature empowers developers with unprecedented control and flexibility over their CI/CD workflows, allowing them to align build schedules with the precise needs of their projects.
Why cron based scheduling works better
Bitrise introduces a cron-based build scheduler, allowing for even more granular automation of build cycles. Cron allows for complex scheduling patterns that can include ranges, intervals, and specific lists of times, offering a different level of flexibility that UI-based schedulers typically cannot match. For instance, you can schedule jobs to run every 5 minutes during business hours on weekdays, which would be cumbersome to set up in a UI-based scheduler.
What is cron syntax?
Cron syntax is a time-based job scheduler format used in Unix-like operating systems. It allows you to specify exact times for tasks to run, down to the minute, using a simple yet flexible string format. The syntax consists of five fields: minute, hour, day of month, month, and day of week.
Here’s a quick breakdown:
+------------ Minute (0 - 59)
| +---------- Hour (0 - 23)
| | +-------- Day of month (1 - 31)
| | | +------ Month (1 - 12) (Jan=1, Feb=2, ..., Dec=12)
| | | | +---- Day of the week (0 - 7) (Sun=0 or 7, Mon=1, Tue=2, ..., Sat=6)
* * * * *
Examples of Cron Expressions:
0 0 * * *
- Runs at midnight every day.30 14 * * 1-5
- Runs at 2:30 PM on weekdays.0 0 1 * *
- Runs at midnight on the first day of every month.*/15 * * * *
- Runs every 15 minutes.0 12 * 12 1-5
- Runs at noon on weekdays in December.
Benefits of Cron-Based Scheduling:
- Granular control: Schedule builds down to the exact minute, accommodating even the most specific project requirements.
- Flexible patterns: Define complex schedules, including ranges, intervals, and specific lists of times, making it easy to set up builds that run every 5 minutes during business hours or at other precise intervals.
- Efficiency: Optimize resource usage by scheduling builds during off-peak hours or distributing them to balance server loads more effectively.
- Scalability: Handle complex and growing project needs without extensive manual configuration.
- Standardization: Leverage a well-documented, widely-understood scheduling standard that ensures consistency across various environments and projects.
Real-Life Scenarios:
Imagine you’re managing a large project that requires regular builds, but only during business hours to maximize resource efficiency. With cron-based scheduling, you can set your builds to run every 30 minutes from 9:00 AM to 5:00 PM on weekdays. Or perhaps you need to run a comprehensive suite of tests overnight—cron syntax allows you to set these builds to start at midnight, ensuring results are ready by the next morning.