【问题标题】:GCP - deploy automatically AppEngine having cron jobGCP - 自动部署具有 cron 作业的 AppEngine
【发布时间】:2019-07-02 12:57:06
【问题描述】:

我在挣扎。我找不到这个问题的解决方案。

我想设置一个 CloudBuild 配置文件 'cloudbuild-preprod.yaml' 来部署应用程序,然后每次我与 git 上的特定分支合并时部署 cron 作业。

部署工作正常。但是当我想添加第二个作业来自动部署 cron 作业时。 GCP 抛出错误。

这是我的 cloudbuild 文件 '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'

这是我的 cron 配置文件“cron-preprod.yaml”:

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

最后这是我的配置文件“compa-api-notifications-preprod.yaml”(没有 cron 作业也可以正常工作)。

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

触发后,第一个作业正常,但第二个作业抛出错误:

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

任何帮助将不胜感激!提前谢谢你

【问题讨论】:

    标签: google-cloud-platform cron continuous-integration google-cloud-build


    【解决方案1】:

    我终于通过将 cron 配置文件从 cron-preprod.yaml 重命名为 cron.yaml 来实现它。如果不命名为 cron.yaml,GCP 将无法理解它是一个 cron 配置文件。

    【讨论】:

    • 如果你想避免在你的管道上多维护一个元素,你可以在这种情况下使用Cloud Scheduler
    猜你喜欢
    • 1970-01-01
    • 2021-01-22
    • 1970-01-01
    • 2021-07-31
    • 1970-01-01
    • 2014-12-08
    • 1970-01-01
    • 2021-05-15
    • 2020-05-30
    相关资源
    最近更新 更多