Google Cloud构建意外的char:位于cloudbuild.yaml中

时间:2019-11-26 19:43:35

标签: google-app-engine google-cloud-platform yaml git-submodules google-cloud-build

我在Google云构建中遇到以下错误

Failed to trigger build: failed unmarshalling build config cloudbuild.yaml: yaml: line 12: could not find expected ':'

我无法在我的:文件中查明我到底在哪里丢失cloudbuild.yaml

steps:
  # Install
  - name: "gcr.io/cloud-builders/npm"
    args: ["install"]
  # Update submodules
  - name: "gcr.io/cloud-builders/git"
    entrypoint: "bash"
    args:
      - "-c"
      - |
      git config -f .gitmodules submodule.myprojectsubmodule.url https://source.developers.google.com/p/myproject/r/github_myprojectsubmodule
      git submodule init
      git submodule update
  # Lint
  - name: "gcr.io/cloud-builders/npm"
    args: ["run", "lint"]
  # Test
  - name: "gcr.io/cloud-builders/npm"
    args: ["run", "test"]
  # Build
  - name: "gcr.io/cloud-builders/gcloud"
    args:
      - kms
      - decrypt
      - --ciphertext-file=.env.enc
      - --plaintext-file=.env
      - --location=global
      - --keyring=myproject
      - --key=cloudbuild-env
  - name: "gcr.io/cloud-builders/npm"
    args: ["run", "build"]
  # Deploy
  - name: "gcr.io/cloud-builders/npm"
    args: ["run", "deploy"]

我使用以下评论https://github.com/GoogleCloudPlatform/cloud-builders/issues/26#issuecomment-463465138添加了# Update submodules步骤

1 个答案:

答案 0 :(得分:1)

要成为有效的yaml格式,请在更新子模块部分的git符号下正确对齐|命令。

# Update submodules
  - name: "gcr.io/cloud-builders/git"
    entrypoint: "bash"
    args:
      - "-c"
      - |
        git config -f .gitmodules submodule.myprojectsubmodule.url https://source.developers.google.com/p/myproject/r/github_myprojectsubmodule
        git submodule init
        git submodule update

在这种情况下,YAML验证器可能很有用,例如https://codebeautify.org/yaml-validator