作者:多米音乐_34014997 | 来源:互联网 | 2022-12-02 17:24
我正在尝试建立Google Cloud Builder构建触发器,以自动构建ASP.NET Core应用并将其部署到Google AppEngine。
使用当前的cloudbuild.yaml:
steps:
- name: 'gcr.io/cloud-builders/dotnet'
args: [ 'publish', '-c', 'Release' ]
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app','deploy','./bin/Release/netcoreapp2.1/publish/app.yaml']
我已经使用cloud-build-local
工具测试了本地构建工作。
这两种方法在本地有效:
从应用程序子目录:cloud-build-local --cOnfig=cloudbuild.yaml --dryrun=false .
从存储库根目录:cloud-build-local --cOnfig=clearbooks-rest-aspnetcore/cloudbuild.yaml --dryrun=false clearbooks-rest-aspnetcore
构建触发器定义似乎部分支持来自存储库根目录(方法2)的子目录中的配置文件,但是似乎假设代码始终位于存储库根目录中。
如何配置Cloud Builder在存储库的子目录中启动构建?
1> Perry Ismang..:
解决方法是更新cloudbuild.yaml
:
dir:
在构建步骤中添加选项
提供正确app.yaml
的部署步骤位置
这是工作中的cloudbuild.yaml:
steps:
- name: 'gcr.io/cloud-builders/dotnet'
args: [ 'publish', '-c', 'Release' ]
dir: 'clearbooks-rest-aspnetcore'
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app','deploy','clearbooks-rest-aspnetcore/bin/Release/netcoreapp2.1/publish/app.yaml']
在本地测试时,请cloud-build-local
在存储库根目录上运行,而不要在app子目录上运行:
cloud-build-local --cOnfig=clearbooks-rest-aspnetcore/cloudbuild.yaml --dryrun=false .
这反映了云构建的工作方式:
正确的cloudbuild.yaml路径
当前源目录