0
votes

I am getting the following error in my google cloud build

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

I can not pinpoint where exactly I am missing : in my cloudbuild.yaml file

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"]

I have added # Update submodules step using the following comment https://github.com/GoogleCloudPlatform/cloud-builders/issues/26#issuecomment-463465138

1
Quotes are missing for # Build \n - name: gcr.io/cloud-builders/gcloud... could be the cause ?Thierry Falvo
That is not the error message I am receiving. It is on line no. 12. However, quotes do not matter in the - name tag.zaq
ok. it's true sorry. I try again ;-). git commands should be aligned under the pipe symbol. I check your yaml format with codebeautify.org/yaml-validator, before and after the correction.Thierry Falvo
Right. They should be aligned with the pipe symbol. You can put your comment as an answer and I will accept it. Thankszaq

1 Answers

1
votes

To be a valid yaml format, the git commands should be correctly aligned under the | symbol in Update submodules section.

# 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

A YAML validator could be useful in this case, for example https://codebeautify.org/yaml-validator.