Google Cloud Build 在使用 Github App 时不会忽略文件

Google Cloud Build does not ignore file when using Github App

我正在使用 Google Cloud Build with Kaniko(用于 docker 层缓存)。

我想在 运行 kaniko 之前添加第一步,但发现当 Github 应用程序发送触发器时,我的 .gcloudignore 没有被考虑在内。当我自己调用命令时它起作用 gcloud builds submit.

.gcloudignore

# If you would like to upload your .git directory, .gitignore file or
# files from your .gitignore file, remove the corresponding line below:
.git
.gitignore
.gcloudignore
.dockerignore
#!include:.gitignore
#!include:.dockerignore

cloudbuild.yaml

steps:
  - name: 'gcr.io/cloud-builders/docker'
    entrypoint: 'bash'
    args:
      - '-c'
      - |
        docker -v && ls -lah
  - name: 'gcr.io/kaniko-project/executor:latest'
    id: 'image-base'
    args:
      - --build-arg=git_hash=$SHORT_SHA

使用 CLI 时效果很好,ls 只显示应该在那里的内容。 但是当 gcb 接收到 github 触发器时,ls -lah 将打印很多应该被 include:.dockerignore

忽略的文件

我不明白,这让我发疯 有人可以帮我吗?

根据定义heregcloud cli 可以在不同的命令中更新文件。使用 .gcloudignore 文件允许 gcloud cli 不上传这些文件。

仅此而已,仅针对gcloud,其他代码上传过程不涉及