简体   繁体   中英

gcloud scheduler create jobs when already exist

I create my gcloud scheduler in command line with

gcloud scheduler jobs create

but when I already deploy my gitlabCI, i got already exist error.

is it possible to overwrite if already exist directly in my gitlabCI?

Suppose you create a Cloud Schedule job with the following attribute values

gcloud scheduler jobs create JOB --location=LOCATION
JOB LOCATION
my-job us-west1
gcloud scheduler jobs create my-job --location=us-west1

In order to verify if the job already exists you may use the gcloud schedule jobs describe JOB command using gcloud CLI.eg https://cloud.google.com/sdk/gcloud/reference/scheduler/jobs/describe

gcloud scheduler jobs describe my-job --location=us-west1

If it indeed already exists, there is no direct way of "overwriting" the existing one, what you can do is to

  • either delete the previous job and re-create it from scratch eg
gcloud scheduler jobs delete my-job
gcloud scheduler jobs create my-job
  • or you can modify the existing job, for instance when you deploy a new version of a service to AppEngine, you can simply reflect this on your existing Cloud Scheduler job without the need to re-creating it entirely.
gcloud scheduler jobs update app-engine my-job --version=VERSION

For more information, please refer to the official documentation for Cloud SDK on Cloud Scheduler https://cloud.google.com/sdk/gcloud/reference/scheduler

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM