Google cloud platform 通过gcloud命令行工具触发特定git提交的构建
我遇到的所有示例都是以下格式:Google cloud platform 通过gcloud命令行工具触发特定git提交的构建,google-cloud-platform,google-kubernetes-engine,google-container-registry,Google Cloud Platform,Google Kubernetes Engine,Google Container Registry,我遇到的所有示例都是以下格式: gcloud container builds submit --config cloudbuild.yaml . 手册页上说: [SOURCE] The source directory on local disk or tarball in Google Cloud Storage or disk to use for this build. If source is a local directory this command s
gcloud container builds submit --config cloudbuild.yaml .
手册页上说:
[SOURCE]
The source directory on local disk or tarball in Google Cloud Storage
or disk to use for this build. If source is a local directory this
command skips files specified in the .gcloudignore file (see $ gcloud
topic gcloudignore for more information).
现在,我的本地磁盘上的源目录非常大,并且花了很多时间将源代码从本地机器传输到Google build servers/cloud。是否有以下两种可能?怎么做
- 提供git/github URL而不是本地源目录
- 顺便说一句,我的git repo也被镜像到了Google源代码库中,因为我已经为我的repo设置了构建触发器。我可以给谷歌镜像的回购协议提供一个URL吗
- 不幸的是,目前在
gcloud
中没有对这一功能的强大支持。不过,您可以通过以下几种其他方式完成此任务:
curl
或您选择的客户端库发送API请求,以请求一个指定。例如:
{
“来源”:{
“报告来源”:{
“回购名称”:“我的回购”,
“commitSha”:“死牛肉”
}
},
“步骤”:[……]
}gcloud
构建它:
git签出和gcloud容器生成提交--config=cloudbuild.yamlcurl
或客户端库对您想要的特定提交发出一个命令如果您正在构建Docker映像,则可以使用。如果您只对构建的最后一层进行了更改,那么实际上可以避免传输大部分数据,而大部分只构建更改 如链接示例中所示,您可以将
--cache from
添加到.yaml文件中,选择要构建的Google容器注册表上的图像:
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['pull', 'gcr.io/$PROJECT_ID/latest-image']
- name: 'gcr.io/cloud-builders/docker'
args: [
'build',
'--cache-from',
'gcr.io/$PROJECT_ID/latest-image',
'-t', 'gcr.io/$PROJECT_ID/latest-image',
'.'
]
images: ['gcr.io/$PROJECT_ID/latest-image']
然后,要生成的命令:
gcloud container builds submit --config cloudbuild.yaml .
这应该可以避免你有相当多的转移时间