我使用Remote builder社区镜像从内部GC ComputeEngine实例下载一些 protected 依赖项。

cloudbuild.yaml 中的此步骤如下所示:

steps:
- name: gcr.io/{PROJECT_NAME}/remote-builder
  env:
  - COMMAND=sudo bash workspace/build.bash
  - ZONE=us-east1-b
  - INSTANCE_NAME=remote-cloud-build
  - INSTANCE_ARGS=--image-project centos-cloud --image-family centos-7

build.bash:
easy_install pip
pip install --upgrade pip
pip install --upgrade setuptools
pip wheel  -r workspace/requirements.txt -w workspace/requirements --no-binary :all:

因此,我将库复制到了workspace/requirements文件夹中。
但是,在下一步构建中,此文件夹中没有文件。
我试图在文件夹中创建空文件进行测试,例如:touch workspace/requirements/file,但是文件夹仍然为空。
你能帮我吗。
先感谢您!

最佳答案

https://cloud.google.com/cloud-build/docs/create-custom-build-steps解释说/workspace目录在每个步骤中都已安装。

我认为执行/workspace时,您位于build.bash目录中,因此可能是您在workspace目录中生成了workspace目录:/workspace/workspace

您可以尝试将/放在workspace前面吗?

steps:
- name: gcr.io/{PROJECT_NAME}/remote-builder
  env:
  - COMMAND=sudo bash /workspace/build.bash
  - ZONE=us-east1-b
  - INSTANCE_NAME=remote-cloud-build
  - INSTANCE_ARGS=--image-project centos-cloud --image-family centos-7


easy_install pip
pip install --upgrade pip
pip install --upgrade setuptools
pip wheel  -r /workspace/requirements.txt -w /workspace/requirements --no-binary :all:

关于docker - Google Cloud Build-结果不会跨步骤保存,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53171386/

10-16 10:15