每次推送到我的存储库的特定分支时,我都有一个触发器来运行构建作业。
如果我尝试使用以下命令“手动”(不使用触发器)运行构建作业:
# Submit the build job
_cmd = f"gcloud builds submit --no-source --config {config['build']['cloudbuild']} --substitutions {substitutions}"
subprocess.run(_cmd, shell=True, check=True)
它按预期工作并成功完成,没有任何问题。但是,如果我对我的存储库执行 git push 以使用触发器执行此操作,则在触发器启动构建作业并从我的 cloudbuild YAML 文件中检测到完整结构后,它会在第一步中断执行并显示错误消息:
第一步:
steps:
# Clone repo to Cloud Build environment
- name: 'gcr.io/cloud-builders/git'
args: ['clone',
'--branch',"$_BRANCH_NAME",
'${_REPO_URL}', '.',
'--depth', '1',
'--verbose']
id: 'Clone Repo'
错误信息:
fatal: destination path '.' already exists and is not an empty directory.
你知道问题可能是什么吗?
提前致谢!
编辑:
尝试在git clone之前清除目录,结果还是一样:
steps:
# Clear Cloud Build environment
- name: 'gcr.io/cloud-builders/git'
args: ['rm', '-rf', '.']
id: 'Clear Cloud Build environment'
# Clone repo to Cloud Build environment
- name: 'gcr.io/cloud-builders/git'
args: ['clone',
'--branch',"$_BRANCH_NAME",
'${_REPO_URL}', '.',
'--depth', '1',
'--verbose']
waitFor: ['Clear Cloud Build environment']
id: 'Clone Repo'