Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Git error when running job in Docker Container

Philip White March 3, 2022

We're running an on-prem installation of Bamboo 6.5. I'm trying to setup a build job to run in a docker container. However, at one point I run a script in the job which runs

git diff master --name-only
This command fails with:
error: object directory /var/atlassian/application-data/bamboo/xml-data/build-dir/_git-repositories-cache/a8a7e8c0985e56b918179b7d01e7ed1189667581/.git/objects does not exist; check .git/objects/info/alternates

fatal: bad object master

 

I have git 1.8 on the server running Bamboo and the Docker container is running git version 2.34.1, which might be the source of the error. I see that Bamboo creates a docker volume for the pulled source, but I do specify that a clean clone be done every time, and I thought the git clone or pull happens in the container, not in the host. I don't think I can update the global version of git on the Bamboo host at this time, and it doesn't seem too easy to install an older version of git in the container.

Any suggestions? 

 

1 answer

1 accepted

0 votes
Answer accepted
Philip White March 4, 2022

I wish I'd read the error message more carefully at first. I had assumed it was having trouble with the .git/object directory in the local repo, but the path is actually the remote, which is some kind of git cache bamboo makes. That remote is in the local file system but was not mapped in the docker container.

So I mapped /var/atlassian/application-data/bamboo/xml-data/build-dir/_git-repositories-cache as a docker volume and I'm able to run git commands within the container now.

I was also mistaken in assuming that the git clone happens inside the container. It happens on the host.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events