Reputation: 11
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 ?
Upvotes: 0
Views: 1327
Reputation: 961
You can try the following steps in your .gitlab-ci
file:
description
? # list scheduler jobs
- >
gcloud scheduler jobs list
--location="LOCATION"
--filter "description='The description for your existing scheduler job'"
--project "YOUR_PROJECT_ID"
--format json
> list.json
# delete the existing scheduler job
- >
for i in $(jq -r .[].name list.json); do
gcloud scheduler jobs delete $i --quiet --project $YOUR_PROJECT_ID || echo "Failed to delete $i"
done
# now re-create your scheduler job
- >
gcloud scheduler jobs create your-scheduler-job
Upvotes: 0
Reputation: 1465
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 .e.g 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
gcloud scheduler jobs delete my-job
gcloud scheduler jobs create my-job
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
Upvotes: 0