cloud-builders: Can't get .git directory to show up in remote builds
I’m submitting a remote build with gcloud container builds submit --config cloudbuild.yaml
and no matter what I try, the .git
directory is not showing up in the temporary tarballs. My Dockerfile needs to access the .git
directory for the build and obviously it can’t find it and all my remote builds fail (local builds work fine).
There is no .dockerignore
, no .gitignore
, no .gcloudignore
, and no “Some files were not included in the source upload.” message like I get in other projects where I use those ignore files.
If I create a different hidden directory:
mkdir .foo
touch .foo/bar
that directory does show up in the tarball, so I know it’s not excluding all hidden directories.
Is there some hardcoding specifically to exclude .git
when creating the tarball?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 29 (5 by maintainers)
@bendory is there a different logic applied when using the GCB GitHub App? I’m trying to get private submodules working, but the extracted tarball doesn’t contain a .git folder
I think it’s worth reopening this issue. I appreciate the thorough answer, @bendory, but it seems the
.gcloudignore
isn’t used when builds are triggered from GitHub.Or is there a separate issue tracking that in particular?
Really the solution here is just for the Cloud Build app to send
.git/
with the rest of the files when a build is triggered, it’s clearly something that people need and its unintuitive that only this one directory is missing.Where would be the right place to file an issue about this?
Indeed, if you look at the code for
gcloudignore
, you’ll see that we generally ignore a.git
directory, since it is rather unusual to want to upload this as part of your build context.If you want it, you have several options:
.gcloudignore
(touch .gcloudignore
).gcloudignore
(or.gitignore
) that ignores the files you don’t want but doesn’t ignore.git
.gcloudignore
that explicitly includes.git
(echo '!.git' > .gcloudignore
)gcloud config set gcloudignore/enabled false
See the gcloudignore documentation for further details.
@saminiemi Your workaround doesn’t work if you want to take advantage of the “Build on PR” feature that’s only available with the Cloud Build GitHub App repo 😦
Also experiencing this issue with the new Cloud Build GitHub App triggers. Have attempted to explicitly add
!.git
to the.gcloudignore
file with no success.@bendory @wlynch - have you been able to recreate this on your end?
Why is this closed? Having a
.git
directory is still required for github triggered builds.That assumption is false. We need the
.git
directory for several reasons, includinggit describe
,git submodule
, andgit lfs
Here’s a
cloudbuild.yaml
file I made to hack around this. This checks out the.git
directory and checks out a private submodule with git-lfs files.We do this instead of moving the repo:
And for authentication we use this project: https://github.com/connectedcars/auth-wrapper
I’m also running into this: with the
.git
directory is not being added to my image in Cloud Build triggered by GitHub, despite having an empty.gcloudignore
present.