在新创建的Google容器构建器中,我无法在构建过程中获取git标签。在构建过程中,默认克隆似乎未获取git标签。我添加了一个自定义生成过程,该过程调用git fetch --tags
,但这会导致错误:Fetching origingit: 'credential-gcloud.sh' is not a git command. See 'git --help'.fatal: could not read Username for 'https://source.developers.google.com': No such device or address
# cloudbuild.yaml
#!/bin/bash
openssl aes-256-cbc -k "$ENC_TOKEN" -in gcr_env_vars.sh.enc -out gcr_env_vars.sh -
source gcr_env_vars.sh
env
git config --global url.https://${CI_USER_TOKEN}@github.com/.insteadOf [email protected]:
pushd vendor
git submodule update --init --recursive
popd
docker build -t gcr.io/project-compute/continuous-deploy/project-ui:$COMMIT_SHA -f /workspace/installer/docker/ui/Dockerfile .
docker build -t gcr.io/project-compute/continuous-deploy/project-auth:$COMMIT_SHA -f /workspace/installer/docker/auth/Dockerfile .
最佳答案
作为第一步,这对我有用:
- name: gcr.io/cloud-builders/git
args: [fetch, --depth=100]
关于google-container-registry - 在Google Cloud Builder中获取标签,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43095321/