-
Bug
-
Resolution: Answered
-
Low
-
None
-
6.6.2
-
None
-
1
-
Severity 3 - Minor
-
Summary
Bamboo checkout fails with "Detached from HEAD" error generating a delay
Environment
- Bamboo 6.6.2
- Bitbucket Server or any git repository.
Steps to Reproduce
- Have a plan with a Checkout task connecting to git or Bitbucket.
- Run Plan.
- Force the checkout to fail so git retries the operation.
- Make a commit in the code in the meantime so the repo will be one step ahead.
Expected Results
Successful checkout
Actual Results
Checkout fails since the task tries to do a full checkout with the original commit hash. In the build logs we see:
simple 04-Oct-2018 14:51:02 Starting task 'Checkout Default Repository' of type 'com.atlassian.bamboo.plugins.vcs:task.vcs.checkout' simple 04-Oct-2018 14:51:02 Checking out into /home/mate/bamboo-home/xml-data/build-dir/PR1-PL1-JOB1 simple 04-Oct-2018 14:51:02 Updating source code to revision: 5c398ea3e77634bd6180aec00ce156b60e958a4a simple 04-Oct-2018 14:51:26 Fetching 'refs/heads/feature/branch1' from 'ssh://git@bitbucket:7999/pr/repo.git'. Will try to do a shallow fetch. simple 04-Oct-2018 14:51:51 Warning: Permanently added '[127.0.0.1]:49307' (RSA) to the list of known hosts. simple 04-Oct-2018 14:51:52 From ssh://127.0.0.1:49307/pr/repo simple 04-Oct-2018 14:51:52 + b767bd0...9d2da7a feature/branch1 -> feature/branch1 (forced update) simple 04-Oct-2018 14:51:52 Checking out revision 5c398ea3e77634bd6180aec00ce156b60e958a4a. simple 04-Oct-2018 14:51:52 fatal: reference is not a tree: 5c398ea3e77634bd6180aec00ce156b60e958a4a error 04-Oct-2018 14:51:52 Checkout to revision 5c398ea3e77634bd6180aec00ce156b60e958a4a has failed. simple 04-Oct-2018 14:51:52 Warning: failed to checkout source code to directory '/home/mate/bamboo-home/xml-data/build-dir/PR1-PL1-JOB1', trying to recover... simple 04-Oct-2018 14:52:34 Cleaned source directory '/home/mate/bamboo-home/xml-data/build-dir/PR1-PL1-JOB1'... simple 04-Oct-2018 14:52:34 Creating local git repository in '/home/mate/bamboo-home/xml-data/build-dir/PR1-PL1-JOB1/.git'. simple 04-Oct-2018 14:52:35 Initialized empty Git repository in /home/mate/bamboo-home/xml-data/build-dir/PR1-PL1-JOB1/.git/ simple 04-Oct-2018 14:53:00 Fetching 'refs/heads/feature/branch1' from 'ssh://git@bitbucket:7999/pr/repo.git'. simple 04-Oct-2018 14:53:24 Warning: Permanently added '[127.0.0.1]:49307' (RSA) to the list of known hosts. simple 04-Oct-2018 14:53:40 From ssh://127.0.0.1:49307/pr/repo simple 04-Oct-2018 14:53:40 * [new branch] feature/branch1 -> feature/branch1 simple 04-Oct-2018 14:53:40 Fetching to source directory '/home/mate/bamboo-home/xml-data/build-dir/PR1-PL1-JOB1' completed, proceeding with checkout... simple 04-Oct-2018 14:53:40 Checking out revision 5c398ea3e77634bd6180aec00ce156b60e958a4a. simple 04-Oct-2018 14:53:43 Note: checking out '5c398ea3e77634bd6180aec00ce156b60e958a4a'. simple 04-Oct-2018 14:53:43 simple 04-Oct-2018 14:53:43 You are in 'detached HEAD' state. You can look around, make experimental simple 04-Oct-2018 14:53:43 changes and commit them, and you can discard any commits you make in this simple 04-Oct-2018 14:53:43 state without impacting any branches by performing another checkout. simple 04-Oct-2018 14:53:43 simple 04-Oct-2018 14:53:43 If you want to create a new branch to retain commits you create, you may simple 04-Oct-2018 14:53:43 do so (now or later) by using -b with the checkout command again. Example: simple 04-Oct-2018 14:53:43 simple 04-Oct-2018 14:53:43 git checkout -b new_branch_name simple 04-Oct-2018 14:53:43 simple 04-Oct-2018 14:53:43 HEAD is now at c1ce76c... fix tests simple 04-Oct-2018 14:53:43 Checkout completed, recover successful. simple 04-Oct-2018 14:53:43 Updated source code to revision: 5c398ea3e77634bd6180aec00ce156b60e958a4a simple 04-Oct-2018 14:53:43 Finished task 'Checkout Default Repository' with result: Success
The build resumes successfully, but with a big delay.
Notes
Although the build is successful, the delay is the problem. Not only problematic for statistical purposes, but having to deal with huge delays for small quick builds.
Workaround
No workaround available.
Suggested solution 1
Have an option to tell the Checkout task to go for the latest commit, always. (Similar to BAM-13576)
Suggested solution 2
Fail build after first failed checkout