Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-18216

Git LFS checkout fails for non-master branch when the Bamboo git cache is empty

    XMLWordPrintable

Details

    Description

      Summary

      Git LFS checkout will fail for any non-master branch if the master branch for that repository hasn't already been fetched into the Bamboo git cache (or the git cache has been cleared). This also occurs on remote agents when caching isn't enabled.

      Steps to Reproduce

      1. Create a Bamboo Plan that uses a source code checkout task to fetch from a git repository with LFS content
      2. Ensure the repository is checking out a non-master branch
      3. Ensure Plan configuration > Repositories > repository > Advanced options > Enable git lfs support is enabled
      4. Note if this repository has been used in the past, you will need to clear the Bamboo git cache for it at Bamboo Administration > Overview > Repository settings first.
      5. Run the plan

      Expected Results

      Checkout completes successfully

      Actual Results

      The below error is shown in the build log or as error during change detection:

      Caused by: com.atlassian.bamboo.repository.RepositoryException: : Cannot fetch branch 'refs/heads/branch' from 'git@bitbucket.org:repo-owner/lfstest.git' to source directory '/var/bamboo-home/xml-data/build-dir/_git-repositories-cache/0334bcb1c6facdb7666ff54b60cdca9e6d2bd69c'. command /usr/bin/git lfs fetch ssh://6f75ebec-a410-486b-b087-5d8c1d0d6a1a@127.0.0.1:45990/repo-owner/lfstest.git failed with code 2. Working directory was [/var/bamboo-home/xml-data/build-dir/_git-repositories-cache/0334bcb1c6facdb7666ff54b60cdca9e6d2bd69c]., stderr:
      Could not fetch
      
      Errors logged to /var/bamboo-home/xml-data/build-dir/_git-repositories-cache/0334bcb1c6facdb7666ff54b60cdca9e6d2bd69c/.git/lfs/objects/logs/20170227T131538.452589247.log
      Use `git lfs logs last` to view the log.
      

      LFS log from git lfs logs last shows:

      $ git-lfs fetch ssh://6f75ebec-a410-486b-b087-5d8c1d0d6a1a@127.0.0.1:45990/repo-owner/lfstest.git
      Could not fetch
      
      Git can't resolve ref: "HEAD"
      

      Workaround

      • See the second workaround for remote agents when caching isn't enabled
      1. Change your repository to clone the master branch and run a build, or create a separate plan that will clone master for the same repository and run a build.
      2. Once master has been cloned into the cache, subsequent branch builds will work.

      This one could result in a rather long clone for a large LFS repository, but it's an option:

      1. Enable fetch whole repository under Plan configuration > Repositories > repository > Advanced Options
      2. Try the build again. If you have caching enabled, this only needs to be performed once.

      If the git cache is cleared for whatever reason (this can happen automatically with some git command failures) and you've used a temporary form of the workaround – you'll need to perform one of the workarounds again.

      Attachments

        Issue Links

          Activity

            People

              achystoprudov Alexey Chystoprudov
              jowen@atlassian.com Jeremy Owen
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: