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

Branch plans with Stash repos are never expired if the branch has already been deleted in Stash

XMLWordPrintable

      For plans with automatic branch management, if a branch is deleted in the VCS repo, the corresponding branch plan will be automatically disabled. It will then be deleted by Bamboo after a number of days (as per the "plan branch cleanup" setting) during the daily 3am branch expiry clean-up.

      With 5.6 we've noticed that some plans are not having their branch plans expired up as they previously were. So far we've found this only affects plans that have a Stash repository (Git repos appear to be unaffected) where the branch has already been deleted from the VCS repo.

      In these cases, the server logs from the 3am clean-up job include errors like this one below:

      2014-08-05 03:00:00,045 INFO [QuartzScheduler_Worker-7] [BranchExpiryJob] Checking branches of Plan My Project - FOO
      2014-08-05 03:00:00,045 INFO [QuartzScheduler_Worker-7] [BranchExpiryJob] Threshold date is Sun Jul 06 00:00:00 UTC 2014
      2014-08-05 03:00:00,568 ERROR [QuartzScheduler_Worker-7] [BranchExpiryJob] Error in chain branch expiry
      com.atlassian.bamboo.plugins.stash.repository.StashRepositoryException: com.atlassian.bamboo.repository.InvalidRepositoryException: Cannot determine head revision of 'ssh://git@stash.example.com:7997/myproject/myrepo.git' on branch 'FOO-123_development_environment_setup'. Branch has probably been removed.
          at com.atlassian.bamboo.plugins.stash.StashRepository.getLastCommit(StashRepository.java:693)
          at com.atlassian.bamboo.plan.branch.BranchExpiryJob.execute(BranchExpiryJob.java:94)
          at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
          at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:49)
          at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:31)
          at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:20)
          at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:52)
          at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
      Caused by: com.atlassian.bamboo.repository.InvalidRepositoryException: Cannot determine head revision of 'ssh://git@stash.example.com:7997/myproject/myrepo.git' on branch 'FOO-123_development_environment_setup'. Branch has probably been removed.
          at com.atlassian.bamboo.plugins.git.NativeGitOperationHelper.obtainLatestRevision(NativeGitOperationHelper.java:543)
          at com.atlassian.bamboo.plugins.git.GitRepository.getLastCommit(GitRepository.java:590)
          at com.atlassian.bamboo.plugins.stash.StashRepository.getLastCommit(StashRepository.java:689)
          ... 7 more
      

      and the branch plan will remain in Bamboo indefinitely (albeit disabled). We have branch plans from 2 months ago, despite 'Plan branch cleanup' being set to 'Remove after 7 days'.

      Workaround
      A temporary workaround to avoid having cluttered with so many branches will be to run this command on your database and restart Bamboo when you have downtime.

      update build set marked_for_deletion=1 where suspended_from_building=1 and build_type="chain_branch";
      

              mgardias Marcin Gardias
              mknight@atlassian.com Michael Knight
              Votes:
              40 Vote for this issue
              Watchers:
              39 Start watching this issue

                Created:
                Updated:
                Resolved: