Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Why Bamboo checkout detached HEAD randomly?

Hi, We have some strange bamboo behavior. 

Some times the check out becomes a 'detached HEAD' some times

06-Feb-2018 04:19:51 * [new branch] master -> master
06-Feb-2018 04:19:51 Checking out revision b5fb1e1796511001b79f8bddec31be2bea3851c6.
06-Feb-2018 04:19:51 /opt/devpg-git/bin/git show-ref master
06-Feb-2018 04:19:51 /opt/devpg-git/bin/git checkout -f b5fb1e1796511001b79f8bddec31be2bea3851c6
06-Feb-2018 04:19:51 Note: checking out 'b5fb1e1796511001b79f8bddec31be2bea3851c6'.
06-Feb-2018 04:19:51
06-Feb-2018 04:19:51 You are in 'detached HEAD' state. You can look around, make experimental
06-Feb-2018 04:19:51 changes and commit them, and you can discard any commits you make in this
06-Feb-2018 04:19:51 state without impacting any branches by performing another checkout.
06-Feb-2018 04:19:51
06-Feb-2018 04:19:51 If you want to create a new branch to retain commits you create, you may
06-Feb-2018 04:19:51 do so (now or later) by using -b with the checkout command again. Example:
06-Feb-2018 04:19:51
06-Feb-2018 04:19:51 git checkout -b <new-branch-name>
06-Feb-2018 04:19:51
06-Feb-2018 04:19:51 HEAD is now at b5fb1e1... update version 2018.06.98
06-Feb-2018 04:19:51 /opt/devpg-git/bin/git remote set-url origin file://nothing
06-Feb-2018 04:19:51 Updated source code to revision: b5fb1e1796511001b79f8bddec31be2bea3851c6

And it usually behave like below

06-Feb-2018 02:54:07 * [new branch] master -> master
06-Feb-2018 02:54:07 Checking out revision bfc85025d8acf93d075c914bfb5e20f64841710b.
06-Feb-2018 02:54:07 /opt/devpg-git/bin/git show-ref master
06-Feb-2018 02:54:07 /opt/devpg-git/bin/git checkout -f master
06-Feb-2018 02:54:07 Already on 'master'
06-Feb-2018 02:54:07 /opt/devpg-git/bin/git remote set-url origin file://nothing
06-Feb-2018 02:54:07 Updated source code to revision: bfc85025d8acf93d075c914bfb5e20f64841710b

Any idea what caused this? 




Using bamboo 6.3.1, no caching on remote agents and no shallow clones


1 answer

1 accepted

2 votes
Answer accepted
Jeyanthan I Atlassian Team Feb 06, 2018

Are you using Source code checkout task to checkout your code in a plan?

it could be possible that your plan is checking out the repository contents from Bamboo caches that is outdated. Bamboo has a cache mechanism that cache the repository and deleting this should fix this issue.

How it works?

At the first run of a plan, Bamboo performs a full clone and stores the data in a local cache directory and complete the build. On subsequent builds, Bamboo does a git fetch from the remote repository to see if there are additional changes and if so, updates the local cache. Similar to the first run, the data for the plan is then checked out from the local cache. Hence, a faster checkout.

How to fix?

In the Bamboo UI, navigate to Bamboo Administration > Overview > Repository Settings.
You can find the name and location of the repository there and hit 'Delete'.

If your build is running on a remote agent, we recommend you to delete in that directory as well just in case. It should be in $BAMBOO_AGENT_HOME/build-dir

Let us know if it helped you. 

Hi, Thanks a lot for the quick reply!!!

But how comes the behavior is different now?

Enable repository caching on remote agentsCache repositories on remote agents to save bandwidth. Note: caches are always full clones of the source repository.

This setting is disabled on the Repository?

Jeyanthan I Atlassian Team Feb 06, 2018

The caching behavior is not changed.

I can think of 2 possible reasons why this could have happened.

  • Bamboo has checked out into a detached HEAD when the user performs force push to overwrite the commits or HEAD.
  • This state could have also happened when you try to re-run failed parts of the build and apparently, that keeps checking out the older commit you had at that point.

Thanks a lot, Jeyanthan

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bamboo

Bamboo Data Center on Kubernetes

Hi, If you are running self-managed environments and looking to adopt modern infrastructure, Bamboo Data Center can now be deployed in a Kubernetes cluster. By leveraging Kubernetes, you can easily...

909 views 3 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you