Google cloud platform Google Cloud Builder-如何在子目录中触发构建配置?

Google cloud platform Google Cloud Builder-如何在子目录中触发构建配置?,google-cloud-platform,google-cloud-build,Google Cloud Platform,Google Cloud Build,我正在尝试建立一个GoogleCloudBuilder构建触发器来自动构建并将我的应用部署到GoogleAppEngine 使用电流: 我已经使用cloudbuildlocal工具测试了本地构建工作 这两种方法在当地奏效: 从应用程序子目录:云构建本地--config=cloudbuild.yaml--dryrun=false。 从存储库根目录:云构建本地--config=clearbooks rest aspnetcore/cloudbuild.yaml--dryrun=false clear

我正在尝试建立一个GoogleCloudBuilder构建触发器来自动构建并将我的应用部署到GoogleAppEngine

使用电流:

我已经使用
cloudbuildlocal
工具测试了本地构建工作

这两种方法在当地奏效:

  • 应用程序子目录
    云构建本地--config=cloudbuild.yaml--dryrun=false。
  • 存储库根目录
    云构建本地--config=clearbooks rest aspnetcore/cloudbuild.yaml--dryrun=false clearbooks rest aspnetcore
  • 构建触发器定义似乎部分支持存储库根目录的子目录中的配置文件(方法2),但它似乎假定代码始终存在于存储库根目录中


    如何配置Cloud Builder以在存储库的子目录中启动构建?

    解决方案是更新
    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子目录上运行:

    cloudbuildlocal--config=clearbooks rest-aspnetcore/cloudbuild.yaml--dryrun=false。

    这反映了云构建的工作方式:

  • 指向正确cloudbuild.yaml的路径
  • 源的当前目录

  • 我猜您需要为
    --config
    @MartinZeitler传递一个绝对路径,我在Build Trigger部分为其传递了绝对路径,但它仍然不起作用,因为它似乎需要源参数来匹配,而Build Trigger definition屏幕却没有显示它。您看到了什么错误消息或错误行为?@JeffreyRennie我现在已经解决了这是通过添加
    dir:
    参数并使用正确的参数进行本地测试来实现的,以反映云构建的工作方式。作为答复张贴。谢谢
    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']