【发布时间】:2021-10-08 14:29:17
【问题描述】:
我正在使用云构建来克隆存储库。我可以确认存储库成功克隆到云构建/workspace 卷。
steps:
- id: 'Clone repository'
name: 'gcr.io/cloud-builders/git'
args: ['clone', $_REPO_URL]
volumes:
- name: 'ssh'
path: /root/.ssh
然后我运行下一步确认
- id: 'List'
name: 'alpine'
args: ['ls']
它告诉我存储库在当前目录中。但是当我尝试将cd 放入目录时,cd 命令不起作用并引发错误:
ERROR: build step 3 "alpine" failed: starting step container failed: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "cd <repo-name>": executable file not found in $PATH: unknown
我的最终目标是cd 进入存储库并运行一些 git 命令。我稍后会使用 alpine,因为 git 构建器映像也不允许我使用 cd。
substitutions:
_REPO_NAME: 'test-repo'
_REPO_URL: 'git@bitbucket.org:example/test-repo.git'
_BRANCH_NAME: 'feature/something'
steps:
- id: 'Clone repository'
name: 'gcr.io/cloud-builders/git'
args: ['clone', $_REPO_URL]
volumes:
- name: 'ssh'
path: /root/.ssh
- id: 'Check Diff'
name: 'alpine'
args: ['cd $_REPO_NAME', '&&', 'git checkout $_BRANCH_NAME', '&&', 'git diff main --name-only']
【问题讨论】:
标签: google-cloud-build cloudbuild.yaml