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

Bamboo doesn't recognise when a deleted branch is recreated in the remote repo

    XMLWordPrintable

Details

    Description

      Summary

      Suppose you have Bamboo "Build Plan" set up to delete "Plan Branches" in case it detects that a branch has been removed from the remote repository after a certain period of time (say the default 7 days).

      In case you remove the branch from the repository and Bamboo detects the branch removal, it will delete the "Plan Branch" after 7 days even if you recreate the Branch on the remote repository in between.

      Details of a use case

      Notes from a Bamboo user:

      I had a branch plan that was disabled (as expected) after the underlying git branch was removed (merged to master). The next day I re-created the git branch and manually went and re-enabled the disabled branch plan and kicked off a new build with my new changes.

      About an hour later, my branch plan was just about to finish but then the page auto-refreshed and showed me a 'page not found' error. The branch plan had been deleted by the 3am scheduled clean-up. I confirmed this from the server logs:

      2015-09-15 03:01:04,003 INFO [scheduler_Worker-8] [BranchExpiryJob] Deleting Plan Branch 'Puppet Continuous Deployment - Puppet CD - BUILDENG-9109-downloads-known-hosts' of Plan 'Puppet Continuous Deployment - Puppet CD' since the VCS branch was deleted 1 days ago.
      

      At this point in time, the branch and branch plan were not deleted or inactive, so it is expected that Bamboo should not have deleted it.

      Steps to Reproduce

      1. Install Bamboo and Stash
      2. Connect them via AppLinks
      3. Create a "Build Plan" and link it to one of your repositories in Stash
      4. Configure the Automatic branch management section of your "Build Plan" to Create plan branches for all new branches. That will automatically set up the Delete branches after a period of time for 7 days.
      5. Create a new branch on your repository from within the Bitbucket server UI
      6. Notice that Bamboo will create a "Plan Branch"
      7. Delete the "Plan Branch" from the Bitbucket server UI
      8. Notice that your "Plan Branch" will be disabled by Bamboo as it detected the branch was removed
      9. Recreate the branch from within the Bitbucket server UI before the expiry date for deleted branches (7 days in this specific example)

      Expected Results

      1. The "Plan branch" should be reenabled by Bamboo
      2. The "Plan branch" shouldn't be marked for deletion anymore
      3. Bamboo deletes a "Plan branch" that is enabled

      Actual Results

      1. The "Plan branch" is not reenabled upon recreation on the remote repo
      2. The branch is deleted according to the "Plan Branch" set up despite the fact it was recreated on the remote repo
      3. Bamboo shouldn't delete a "Plan branch" that is enabled

      Workaround

      1. You could check which branch has been detected for deletion:

      bamboo=# select * from vcs_branch;
       vcs_branch_id |          name           | detected_deletion_date  | chain_id 
      ---------------+-------------------------+-------------------------+----------
             1867783 | bugfix/thirdnewbranch   |                         |  1474568
             1867784 | bugfix/anewbranch       |                         |  1474568
             1867785 | bugfix/branch           |                         |  1474568
             1867786 | bugfix/athirdnewbranch  |                         |  1474568
             1867787 | bugfix/asecondnewbranch |                         |  1474568
             1867788 | master                  |                         |  1474568
             1867789 | bugfix/branchtest       | 2015-10-08 10:22:52.241 |  1474568
             1867790 | bugfix/branch           | 2015-10-08 10:31:44.442 |  1474568
      

      2. Then you can set the detected_deletion_date to NULL:

      update vcs_branch set detected_deletion_date=NULL where vcs_branch_id=1867790;
      

      3. Check it again that the branch has not been marked for deletion:

      bamboo=# select * from vcs_branch;
       vcs_branch_id |          name           | detected_deletion_date  | chain_id 
      ---------------+-------------------------+-------------------------+----------
             1867783 | bugfix/thirdnewbranch   |                         |  1474568
             1867784 | bugfix/anewbranch       |                         |  1474568
             1867785 | bugfix/branch           |                         |  1474568
             1867786 | bugfix/athirdnewbranch  |                         |  1474568
             1867787 | bugfix/asecondnewbranch |                         |  1474568
             1867788 | master                  |                         |  1474568
             1867789 | bugfix/branchtest       | 2015-10-08 10:22:52.241 |  1474568
             1867790 | bugfix/branch           |                         |  1474568
      

      4. You can manually reenable the "Plan Branch" by using the Bamboo UI

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mknight@atlassian.com Michael Knight
              Votes:
              55 Vote for this issue
              Watchers:
              56 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: