AsmaG
AsmaG

Reputation: 507

GCP - deploy automatically AppEngine having cron job

I am struggling. I can't find a solution for this issue.

I want to set a CloudBuild config file 'cloudbuild-preprod.yaml' that deploys the app and then deploy the cron job every time I merge with a specific branch on git.

The deployment works fine. But When I wanted to add a second job to automate deployment of the cron job. GCP throws an error.

Here's my cloudbuild file 'cloudbuild-preprod.yaml'

steps:
- name: "gcr.io/cloud-builders/gcloud"
  args: ["app", "deploy", 'app/compa-api-notifications-preprod.yaml']
- name: "gcr.io/cloud-builders/gcloud"
  args: ["app", "deploy", 'app/cron-preprod.yaml']
timeout: '1200s'

Here's my cron config file 'cron-preprod.yaml':

cron:
- description: "monthly summary estimations"
  url: /v1/sendMailEstimationsReminders
  schedule: 1 of month 09:00
  retry_parameters:
    job_retry_limit: 1

And finally Here's my config file 'compa-api-notifications-preprod.yaml' (This works fine without the cron job).

env: flex
runtime: nodejs
service: compa-notifications
manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

When Triggered, The first Job works fine but the second job throws an error:

ERROR: build step 1 "gcr.io/cloud-builders/gcloud" failed: exit status 1
ERROR
Finished Step #1
Step #1:   in "/workspace/app/cron-preprod.yaml", line 2, column 1
Step #1: Unexpected attribute 'cron' for object of type AppInfoExternal.
Step #1: ERROR: (gcloud.app.deploy) An error occurred while parsing file: [/workspace/app/cron-preprod.yaml]
Step #1: Already have image (with digest): gcr.io/cloud-builders/gcloud
Starting Step #1

any help would be appreciated ! Thank you in advance

Upvotes: 2

Views: 1187

Answers (1)

AsmaG
AsmaG

Reputation: 507

I finally Got it working by just renaming the cron config file from cron-preprod.yaml to cron.yaml. GCP won't understand it's a cron config file if it is not named cron.yaml.

Upvotes: 8

Related Questions