Samuel Bodin
Samuel Bodin

Reputation: 15

Google Cloud Build does not ignore file when using Github App

I'm using Google Cloud Build with Kaniko (for docker layer caching).

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. It works when I call the command myself 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

When using the CLI it works well, the ls is showing only what should be there. But when gcb receive a github trigger the ls -lah will print a lot of files that should be ignored with the include:.dockerignore

I don't understand and it drives me insane 😆 Can someone help me please?

Upvotes: 0

Views: 1168

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75820

As defined here, gcloud cli can update files in different commands. using a .gcloudignore file allows gcloud cli to not upload these files.

That's all, it's only for gcloud, not for other code upload process.

Upvotes: 3

Related Questions