Stewart Bryson
Stewart Bryson

Reputation: 13

Google CloudBuild artifacts YAML

I've followed the docs for Google CloudBuild here: https://cloud.google.com/cloud-build/docs/configuring-builds/store-images-artifacts

So here's my cloudbuild.yaml configuration:

steps:
- name: gcr.io/cloud-builders/git
id: git-checkout
args: [ 'fetch','--tags','--unshallow']
- name: openjdk
id: gradle-build
args: [
    './gradlew',
    '--build-cache',
    '-Si',
    '-Panalytics.buildId=$BUILD_ID',
    '-PgithubToken=$_GITHUB_TOKEN',
    '-g', '$_GRADLE_CACHE',
    'build'
]
artifacts:
objects:
    location: ['gs://my-bucket/artifacts/']
    paths: ["build/libs/*.jar"]

If I comment out, the following, then it runs successfully:

artifacts:
objects:
    location: ['gs://my-bucket/artifacts/']
    paths: ["build/libs/*.jar"]

Without comments, I get the following error from the CloudBuild console:

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

And under the Logs section, it simply says Logs unavailable.

Upvotes: 1

Views: 2581

Answers (3)

Regn
Regn

Reputation: 281

objects.location element should not be an array.

The following should work:

artifacts:
  objects:
    location: 'gs://my-bucket/artifacts/'
    paths: ["build/libs/*.jar"]

Upvotes: 0

Chris Stryczynski
Chris Stryczynski

Reputation: 33861

I've also run into this error with a section of my cloudbuild.yaml file looking like:

- name: 'gcr.io/cloud-builders/git'
  args:
  - clone 
  - -depth
  - 1
  - --single-branch
  - -b
  - development
  - [email protected]:aoaoeuoaeuoeaueu/oaeueoaueoauoaeuo.git
  volumes:
  - name: 'ssh'
    path: /root/.ssh

Seems the issue is with the 1. So I just added quotes around which fixed it (- "1").

Upvotes: 0

user2605764
user2605764

Reputation: 21

You may need to indent objects: line

artifacts:
  objects:
    location: ['gs://my-bucket/artifacts/']
    paths: ["build/libs/*.jar"]

Upvotes: 2

Related Questions