R/cloudbuild_schedule.R
cr_build_schedule_http.RdThis enables Cloud Scheduler to trigger Cloud Builds
cr_build_schedule_http(
build,
email = cr_email_get(),
projectId = cr_project_get()
)
cr_schedule_build(
build,
schedule,
schedule_type = c("http", "pubsub"),
schedule_pubsub = NULL,
email = cr_email_get(),
projectId = cr_project_get(),
...
)A Build object created via cr_build_make or cr_build
The email that will authenticate the job set via cr_email_set
The projectId
A cron schedule e.g. "15 5 * * *"
Whether to use HTTP or PubSub styled schedules
If you have a custom pubsub message to send via an existing topic, use cr_schedule_pubsub to supply it here
Arguments passed on to cr_schedule
regionThe region usually set with cr_region_set
overwriteIf TRUE and an existing job with the same name exists, will overwrite it with the new parameters
nameName to call your scheduled job
httpTargetA HTTP target object HttpTarget
pubsubTargetA Pub/Sub target object PubsubTarget such as created via cr_schedule_pubsub
descriptionOptionally caller-specified in CreateJob or
timeZoneSpecifies 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.
A HttpTarget object for use in cr_schedulea HttpTarget object for use in cr_scheduleA cloud scheduler Job object
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
See also cr_schedule_pubsub which you can use by creating a build trigger of your build via cr_buildtrigger that accepts Pub/Sub messages. This method is recommended as being easier to maintain than using HTTP requests to the Cloud Build API that cr_build_schedule_http produces.
https://cloud.google.com/build/docs/api/reference/rest/v1/projects.builds/create
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_pubsub(),
cr_schedule_run(),
cr_schedule()
cloudbuild <- system.file("cloudbuild/cloudbuild.yaml", package = "googleCloudRunner")
build1 <- cr_build_make(cloudbuild)
build1
#> ==CloudBuildObject==
#> steps:
#> - name: gcr.io/cloud-builders/docker
#> id: Docker Version
#> args: version
#> - name: alpine
#> id: Hello Cloud Build
#> args:
#> - echo
#> - Hello Cloud Build
#> - name: rocker/r-base
#> id: Hello R
#> args:
#> - Rscript
#> - -e
#> - paste0('1 + 1 = ', 1+1)
if (FALSE) {
cr_schedule("cloud-build-test1",
schedule = "15 5 * * *",
httpTarget = cr_build_schedule_http(build1)
)
# a cloud build you would like to schedule
itworks <- cr_build("cloudbuild.yaml", launch_browser = FALSE)
# once working, pass in the build to the scheduler
cr_schedule("itworks-schedule",
schedule = "15 5 * * *",
httpTarget = cr_build_schedule_http(itworks)
)
}