Google CloudBuild工件YAML

时间:2018-08-29 14:57:01

标签: google-cloud-build

我在这里关注了Google CloudBuild的文档:https://cloud.google.com/cloud-build/docs/configuring-builds/store-images-artifacts

这是我的cloudbuild.yaml配置:

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

如果我注释掉以下内容,则它可以成功运行:

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

没有注释,我从CloudBuild控制台收到以下错误:

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

Logs 部分下,它只是说日志不可用

3 个答案:

答案 0 :(得分:2)

您可能需要缩进objects:

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

答案 1 :(得分:0)

我也遇到了这个错误,我的cloudbuild.yaml文件的一部分看起来像这样:

- name: 'gcr.io/cloud-builders/git'
  args:
  - clone 
  - -depth
  - 1
  - --single-branch
  - -b
  - development
  - git@bitbucket.org:aoaoeuoaeuoeaueu/oaeueoaueoauoaeuo.git
  volumes:
  - name: 'ssh'
    path: /root/.ssh

似乎问题出在1上。因此,我只添加了一些引号来固定它(- "1")。

答案 2 :(得分:0)

objects.location元素不能是数组。

以下方法应该起作用:

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