Skip to content
← Back to activity

Public problem

Remote Cloud Build excludes the .git directory from the build context

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

Submitting a remote build with gcloud container builds submit --config cloudbuild.yaml, the .git directory never showed up in the build context even though there was no .dockerignore, no .gitignore, no .gcloudignore, and no "Some files were not included" message. Other hidden directories (like a test .foo dir) did show up, so only .git was being excluded. The Dockerfile needed .git to stamp the git revision into the app, so all remote builds failed while local builds worked.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

gcloud's default ignore behavior always excludes .git from the upload tarball, and it does so silently. To include it, override the ignore rules: create an empty .gcloudignore (touch .gcloudignore), write a .gcloudignore that does not ignore .git, add an explicit !.git line to .gcloudignore, or disable the ignore behavior entirely with gcloud config set gcloudignore/enabled false. The reporter confirmed one of these got their remote build working.

Source: https://github.com/GoogleCloudPlatform/cloud-builders/issues/236

Source: https://github.com/GoogleCloudPlatform/cloud-builders/issues/236