Google CloudBuild 工件 YAML

Google CloudBuild artifacts YAML

我在此处遵循 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 部分下,它简单地显示 Logs unavailable.

您可能需要缩进 objects:

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

我也 运行 遇到了这个错误,我的 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")。

objects.location 元素不应该是数组。

以下应该有效:

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