Scheduling daily and hourly builds
Using Semaphore’s build scheduler allows you to run a build, or any kind of job, on a daily or hourly basis. This is useful in a number of use cases:
- Your workflow depends on performing nightly builds.
- Performing automated QA tests on a remote application.
- You have an inactive project but would like to be sure that the code still works with its dependencies.
- An easy way to periodically execute arbitrary code, track results and receive notifications.
To use the scheduler, go to your project settings and open the “Build Scheduler” tab.
Select the branch on which the build scheduler should perform. By default this is the master branch.
Select whether you’d like your builds to run daily or hourly. Note that in case of daily builds, the time you select is in UTC time zone. For hourly builds, you can choose whether they will run at the beginning of every hour (XX:00), or mid-hour (XX:30).
Finally, click on “Enable build scheduler” and save your settings.
Your scheduled builds will appear in the project timeline.
From the moment they run, scheduled builds behave exactly like any other build on Semaphore: they execute currently configured build commands and, depending on your other configuration, may trigger notifications or an automated deploy.
There is an automatically exported environment variable called
SEMAPHORE_TRIGGER_SOURCE which will be set to “scheduler” if the build is
triggered by the build scheduler. This can be used for specifying commands that
you want to execute only in this kind of builds like:
if [ "$SEMAPHORE_TRIGGER_SOURCE" = "scheduler" ]; then bundle exec rake spec:nightly ; fi