Run Jenkins jobs on a schedule

Recipe ToolsMarketingDeveloper ToolAPI Integration

What it does

When a scheduled interval arrives, this automation retrieves a Jenkins crumb and runs a Jenkins job via HTTP requests. It logs the outcome to a job report so someone knows whether the job started.

Who it's for

Engineering teams who need to run Jenkins jobs on a schedule without manual intervention.

How teams use this

Run nightly builds without manual steps

Set Clock to run every night at a specific time, and the Jenkins job starts automatically. The team no longer needs to start builds manually, and the log shows each run.

Run different jobs by project

Extend this automation to accept a project name parameter so different Jenkins jobs can be run from the same schedule. Add a condition to route each project to its own job endpoint.

Notify the team on job failure

Retarget the log step to send a Slack message instead, so the team is notified immediately if the Jenkins job fails to start. The schedule and HTTP requests stay the same.

Run builds for multiple environments

Add a filter to check the environment name and route each one to a different Jenkins endpoint. This lets someone run builds for staging or production from a single schedule.

How it works

  1. Wait for the scheduled interval. At the specified time or recurring schedule, Clock starts this automation and prepares to run the Jenkins job.
  2. Retrieve Jenkins crumb via Rest. Send an HTTP request through Rest to Jenkins to retrieve a crumb token, which is required to authenticate the job request.
  3. Run Jenkins job via Rest. Send an HTTP request through Rest to Jenkins with the crumb and job parameters to start the build. If an error occurs, the job is not retried.
  4. Log the result to job report. Record whether the Jenkins job started or failed so the team can review the outcome in the job report.