3

When I use my cloudbuild.yaml with CloudBuild trigger, it fails with:

failed unmarshalling build config cloudbuild.yaml: json: cannot unmarshal string into Go value of type []json.RawMessage

I already reduced my cloudbuild.yaml to

steps:
  - name: "gcr.io/skynet-2359/sonar-scanner"
    waitFor: "-"
    args: [
      "-Dsonar.projectKey=xxx",
      "-Dsonar.sources=./src",
      "-Dsonar.host.url=http://sonarqube....",
      "-Dsonar.login=${_SONAR_TOKEN}"
    ]

substitutions:
  _SONAR_TOKEN: "..."

The build works if I use the CLI way to start:

gcloud builds submit --config cloudbuild.yaml .
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805
  • Have you checked this thread? Seems to be discussing a similar issue, it does not explain why it succeeds locally but might be worth checking your sonar token size: https://stackoverflow.com/questions/51539273/cloudbuil-yaml-does-not-unmarshall-when-using-base64-encoded-value-on-build-trig – Parth Mehta Dec 08 '19 at 09:32
  • @ParthMehta found the issue. Mine was because I didnt use array for waitFor – Jiew Meng Dec 08 '19 at 14:39

1 Answers1

3

Found the issue. waitFor should be an array:

steps:
  - name: "gcr.io/skynet-2359/sonar-scanner"
    waitFor: ["-"]
    args: [
      "-Dsonar.projectKey=xxx",
      "-Dsonar.sources=./src",
      "-Dsonar.host.url=http://sonarqube....",
      "-Dsonar.login=${_SONAR_TOKEN}"
    ]

substitutions:
  _SONAR_TOKEN: "..."
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805