我们可以在cloudbuild yaml文件中重复使用相同的构建步骤吗

问题描述 投票:0回答:2

在GCP云构建yaml文件中,我们可以通过再次传递相同的参数但使用不同的文件名来重复使用这些步骤吗? 例如:

- name: 'gcr.io/cloud-builders/gke-deploy'
  args:
    - run
    - '--filename=kubernetes-job'
    - '--image=asia-south1-docker.pkg.dev/product-staging-apps/test-stg-repo/staging-app:$SHORT_SHA'
    - '--location=asia-south1'
    - '--cluster=stg-gke-cluster'
  id: 'job'
- name: 'gcr.io/cloud-builders/gke-deploy'
  args:
    - run
    - '--filename=kubernetes-app'
    - '--image=asia-south1-docker.pkg.dev/product-staging-apps/test-stg-repo/staging-app:$SHORT_SHA'
    - '--location=asia-south1'
    - '--cluster=stg-gke-cluster'
  waitFor: ['job']

我尝试通过设置上述内容,第一次部署成功,第二次部署抛出错误 -

 Error: failed to prepare deployment: failed to save suggested configuration files to "output/suggested": output directory "output/suggested" exists and is not empty
kubernetes google-cloud-platform google-kubernetes-engine cloudbuild.yaml
2个回答
0
投票

尝试设置

--output=./foo
以使用不同的目录。

- name: 'gcr.io/cloud-builders/gke-deploy'
  args:
    - run
    - '--filename=kubernetes-job'
    - '--image=asia-south1-docker.pkg.dev/product-staging-apps/test-stg-repo/staging-app:$SHORT_SHA'
    - '--location=asia-south1'
    - '--cluster=stg-gke-cluster'
    - '--output=./job-output'
  id: 'job'
- name: 'gcr.io/cloud-builders/gke-deploy'
  args:
    - run
    - '--filename=kubernetes-app'
    - '--image=asia-south1-docker.pkg.dev/product-staging-apps/test-stg-repo/staging-app:$SHORT_SHA'
    - '--location=asia-south1'
    - '--cluster=stg-gke-cluster'
    - '--output=./app-output'
  waitFor: ['job']


-2
投票

这是我一直在使用的,你可以考虑它,因为解决方法可能会有所帮助。

Cloudbuild.yaml

- id: 'build test core image'
  name: 'gcr.io/cloud-builders/docker'
  args: ['build', '-t', 'gcr.io/$PROJECT_ID/$REPO_NAME/$BRANCH_NAME:$SHORT_SHA', '.']
- id: 'push test core image'
  name: 'gcr.io/cloud-builders/docker'
  args: ['push', 'gcr.io/$PROJECT_ID/$REPO_NAME/$BRANCH_NAME:$SHORT_SHA']
© www.soinside.com 2019 - 2024. All rights reserved.