简体   繁体   English

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

[英]Google Cloud Build does not ignore file when using Github App

I'm using Google Cloud Build with Kaniko (for docker layer caching).我将 Google Cloud Build 与 Kaniko 结合使用(用于 docker 层缓存)。

I wanted to add a first step before running kaniko and realised that my .gcloudignore is not taken into account when Github app send the trigger.我想在运行 kaniko 之前添加第一步,并意识到当 Github 应用程序发送触发器时,我的.gcloudignore没有被考虑在内。 It works when I call the command myself gcloud builds submit .当我自己调用命令gcloud builds submit时它起作用了。

.gcloudignore .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 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

When using the CLI it works well, the ls is showing only what should be there.使用 CLI 时效果很好,ls 只显示应该在那里的内容。 But when gcb receive a github trigger the ls -lah will print a lot of files that should be ignored with the include:.dockerignore但是当 gcb 收到一个 github 触发器时, ls -lah将打印很多应该被 include:.dockerignore 忽略的文件

I don't understand and it drives me insane Can someone help me please?我不明白,这让我发疯有人可以帮助我吗?

As defined here , gcloud cli can update files in different commands. gcloud cli可以在不同的命令中更新文件。 using a .gcloudignore file allows gcloud cli to not upload these files.使用.gcloudignore文件允许gcloud cli 不上传这些文件。

That's all, it's only for gcloud , not for other code upload process.仅此而已,它仅针对gcloud ,不适用于其他代码上传过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM