We have the following in our cloudbuild.yaml file and it is creating our cloud scheduler job as expected.
steps:
# deploy cloud scheduler job
- name: "gcr.io/cloud-builders/gcloud"
args: ["scheduler", "jobs", "create", "pubsub", "my_job_name", "--schedule=0 0 * * 1-5", "--topic=my_topic", "--message-body=My Message", "--description=My Description", "--time-zone=America/MyTimeZone"]
However, once cloud build is triggered again we get the following error:
ERROR: (gcloud.scheduler.jobs.create.pubsub) ALREADY_EXISTS: ....
We would like to keep this in our cloudbuild rather than manually creating in console. How would we, if possible, restructure the build steps and/or maybe add a cloud function in python37 that would check if the job exists, if not create. If job exists and no changes, continue. If changes are present then update.
Any feedback, suggestions or examples provided will be appreciated!
Thanks