This enables Cloud Scheduler to trigger Cloud Builds

cr_build_schedule_http(
  build,
  email = cr_email_get(),
  projectId = cr_project_get()
)

cr_schedule_http(build, email = cr_email_get(), projectId = cr_project_get())

cr_schedule_pubsub(
  topicName,
  PubsubMessage = NULL,
  data = NULL,
  attributes = NULL,
  projectId = cr_project_get()
)

cr_schedule(
  name,
  schedule = NULL,
  httpTarget = NULL,
  pubsubTarget = NULL,
  description = NULL,
  overwrite = FALSE,
  timeZone = Sys.timezone(),
  region = cr_region_get(),
  projectId = cr_project_get()
)

Arguments

build

A Build object created via cr_build_make or cr_build

email

The email that will authenticate the job set via cr_email_set

projectId

The GCP project to run within usually set with cr_project_set

topicName

The name of the Cloud Pub/Sub topic or a Topic object from topics_get

PubsubMessage

A PubsubMessage object generated via PubsubMessage. If used, then do not send in `data` or `attributes` arguments as will be redundant since this variable will hold the information.

data

The message payload for PubsubMessage. An R object that will be turned into JSON via [jsonlite] and then base64 encoded into the PubSub format.

attributes

Attributes for PubsubMessage.

name

Name to call your scheduled job

schedule

A cron schedule e.g. "15 5 * * *"

httpTarget

A HTTP target object HttpTarget

pubsubTarget

A Pub/Sub target object PubsubTarget such as created via cr_schedule_pubsub

description

Optionally caller-specified in CreateJob or

overwrite

If TRUE and an existing job with the same name exists, will overwrite it with the new parameters

timeZone

Specifies the time zone to be used in interpreting schedule. If set to NULL will be "UTC". Note that some time zones include a provision for daylight savings time.

region

The region usually set with cr_region_set

Value

cr_schedule_http returns a HttpTarget object for use in cr_schedulecr_schedule_pubsub returns a PubsubTarget object for use within cr_schedule or cr_schedule_buildA gar_scheduleJob class object

Details

Ensure you have a service email with cr_email_set of format service-{project-number}@gcp-sa-cloudscheduler.iam.gserviceaccount.com with Cloud Scheduler Service Agent role as per https://cloud.google.com/scheduler/docs/http-target-auth#add

You can parametrise builds by sending in values within PubSub. To read the data in the message set a substitution variable that picks up the data. For example _VAR1=$(body.message.data.var1)

If your schedule to PubSub fails with a permission error, try turning the Cloud Scheduler API off and on again the Cloud Console, which will refresh the Google permissions.

See also

https://cloud.google.com/build/docs/api/reference/rest/v1/projects.builds/create

Google Documentation for Cloud Scheduler

Other Cloud Scheduler functions: HttpTarget(), Job(), PubsubTarget(), cr_run_schedule_http(), cr_schedule_delete(), cr_schedule_get(), cr_schedule_list(), cr_schedule_pause(), cr_schedule_run()

Other Cloud Scheduler functions: HttpTarget(), Job(), PubsubTarget(), cr_run_schedule_http(), cr_schedule_delete(), cr_schedule_get(), cr_schedule_list(), cr_schedule_pause(), cr_schedule_run()

Examples