Bamboo Repository Tag task fails when .git/objects does not exist

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary


The Repository Tag fails to run and the following error message is thrown inside the build/ error log available from the build result summary page:

com.atlassian.bamboo.task.TaskException: An error occurred while tagging a repository
	at com.atlassian.bamboo.plugins.vcs.task.VcsTagTask.execute(VcsTagTask.java:64)
	at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$3(TaskExecutorImpl.java:323)
	at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:258)
	at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:323)
	at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:118)
	at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:73)
	at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.executeBuildPhase(DefaultBuildAgent.java:205)
	at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:177)
	at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.lambda$waitAndPerformBuild$0(BuildAgentControllerImpl.java:168)
	at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:118)
	at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:161)
	at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.lambda$start$0(DefaultBuildAgent.java:122)
	at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48)
	at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)
	at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)
	at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41)
	at java.lang.Thread.run(Thread.java:748)
Caused by: com.atlassian.bamboo.plugins.git.GitCommandException: command [/usr/bin/git tag v1 'error: object directory /home/xml-data/build-dir/_git-repositories-cache/ffe5cbc402551315a1e4836f88f8812b61bf95fa/.git/objects does not exist; check .git/objects/info/alternates.31b41fbbc8c6f7185678e635d23f0360d1e70e00'] failed with code 128. Working directory was [/home/local-working-dir/51544065/PROJ-PLAN-JOB1]., stderr:
fatal: Failed to resolve 'error: object directory /home/xml-data/build-dir/_git-repositories-cache/ffe5cbc402551315a1e4836f88f8812b61bf95fa/.git/objects does not exist; check .git/objects/info/alternates.31b41fbbc8c6f7185678e635d23f0360d1e70e00' as a valid ref.
	at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runCommand(GitCommandProcessor.java:746)
	at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runCommand(GitCommandProcessor.java:675)
	at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runCommand(GitCommandProcessor.java:666)
	at com.atlassian.bamboo.plugins.git.NativeGitOperationHelper.createLightweightTag(NativeGitOperationHelper.java:764)
	at com.atlassian.bamboo.plugins.git.v2.GitTagCreator.createTag(GitTagCreator.java:48)
	at com.atlassian.bamboo.plugins.stash.v2.BitbucketServerTagCreator.createTag(BitbucketServerTagCreator.java:18)
	at com.atlassian.bamboo.plugins.vcs.task.VcsTagTask.execute(VcsTagTask.java:61)
	... 16 more

Environment

All Bamboo versions.

Diagnosis

Bamboo keeps a local cache (copy) of Git repositories in two places: on its own server (Bamboo version  7.2.5 under <bamboo-home>/xml-data/build-dir/_git-repositories-cache and Bamboo  8.0.0 under <bamboo-home>/local-working-dir/_git-repositories-cache) as well as on the agent server (under <agent-home>/xml-data/build-dir/_git-repositories-cache). The agent cache is optional and can be changed from the repository configuration inside Bamboo (Repository configuration > Advanced options > Enable repository caching on agents).

What Bamboo is trying to do when the task fails is run "git tag" to create the tag inside the repository cache before pushing it back to the remote repository. You can try and do the same "git tag" operation manually (for diagnosing purposes) inside the repository cache folder and observe the results. The fact that Bamboo reports there's no objects folder inside the cache is a sign that it was corrupted.

Cause

Repository cache is corrupted.

Solution

The solution is to recreate the repository cache:

  1. Go to the Bamboo administration > Overview > Repository settings page.
  2. Take note of the folder name from the error message. In this example it is ffe5cbc402551315a1e4836f88f8812b61bf95fa.
  3. Find the cache (e.g. ffe5cbc402551315a1e4836f88f8812b61bf95fa) in the list and click 'Delete'.
  4. At the top of the page you should see a message that says:

    Deleted Git cache 'ffe5cbc402551315a1e4836f88f8812b61bf95fa'
    Scheduling unused Git Caches deletion on agents: X
  5. Go back to the plan that failed and trigger another build.

The first build that gets triggered after removing the cache usually takes a little longer to run because Bamboo has to create the cache before dispatching the build.

Last modified on Nov 12, 2021

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.