在云构建中更改目录'cd'未找到



我正在使用云构建克隆存储库。我可以确认存储库成功克隆到云构建/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']

您可以使用bash运行任何您想要的命令。下面是我在一个项目中使用的一个例子:

- name: 'gcr.io/cloud-builders/git'
id: Clone env repository
entrypoint: /bin/sh
args:
- '-c'
- |
git clone git@github.com:xyz/abc.git && 
cd gitops-env-repo/ && 
git checkout dev   

在*。yaml文件。

steps:
- name: string
args: [string, string, ...]
env: [string, string, ...]
dir: string
id: string
waitFor: [string, string, ...]
entrypoint: string
secretEnv: string
volumes: object(Volume)
timeout: string (Duration format)
- name: string
...
- name: string
...
timeout: string (Duration format)
queueTtl: string (Duration format)
logsBucket: string
options:
env: [string, string, ...]
secretEnv: string
volumes: object(Volume)
sourceProvenanceHash: enum(HashType)
machineType: enum(MachineType)
diskSizeGb: string (int64 format)
substitutionOption: enum(SubstitutionOption)
dynamicSubstitutions: boolean
logStreamingOption: enum(LogStreamingOption)
logging: enum(LoggingMode)
pool: object(PoolOption)
substitutions: map (key: string, value: string)
tags: [string, string, ...]
serviceAccount: string
secrets: object(Secret)
availableSecrets: object(Secrets)
artifacts: object (Artifacts)
images:
- [string, string, ...]

https://cloud.google.com/build/docs/build-config-file-schema

相关内容

  • 没有找到相关文章

最新更新