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

      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

            [BAM-16341] Bamboo doesn't recognise when a deleted branch is recreated in the remote repo

            Monique Khairuliana (Inactive) made changes -
            Workflow Original: Bamboo Workflow 2016 v1 - Restricted [ 1433101 ] New: JAC Bug Workflow v3 [ 3385854 ]
            Status Original: Resolved [ 5 ] New: Closed [ 6 ]

            maclun added a comment -

            I have just experienced it with a couple of our Build Plan Branches.

            Version: 6.7.1 build 60705 - 18 Oct 18

            Scenario:

            Day 1:

            • Create new branch 'X' in Bitbucket
            • 'X' gets created automatically in two Bamboo Build Plans
            • 'X' gets deleted manually in Bitbucket due to mistake
            • 'X' gets created again from proper hash
            • Bamboo Build Plan Branches 'X' are re-enabled manually
            • Couple of other branches (before 'X-1' are renamed to be 'X' and point to be Bitbucket branch)

            Day 2:

            • All branches are gone in Bamboo (we have setting to clean them after zero days)

            maclun added a comment - I have just experienced it with a couple of our Build Plan Branches. Version: 6.7.1 build 60705 - 18 Oct 18 Scenario: Day 1: Create new branch 'X' in Bitbucket 'X' gets created automatically in two Bamboo Build Plans 'X' gets deleted manually in Bitbucket due to mistake 'X' gets created again from proper hash Bamboo Build Plan Branches 'X' are re-enabled manually Couple of other branches (before 'X-1' are renamed to be 'X' and point to be Bitbucket branch) Day 2: All branches are gone in Bamboo (we have setting to clean them after zero days)

            I have also just run into this problem.

            Pushed new branch, build kicked off, merged PR in Bitbucket and checked the box to delete the branch.

            A few days later we needed to make a change. The branch was re-created with the same name, pushed, build did not kick off. Bitbucket refuses to allow merge because there are no successful builds.

            This is very annoying.

            Derek White added a comment - I have also just run into this problem. Pushed new branch, build kicked off, merged PR in Bitbucket and checked the box to delete the branch. A few days later we needed to make a change. The branch was re-created with the same name, pushed, build did not kick off. Bitbucket refuses to allow merge because there are no successful builds. This is very annoying.
            Owen made changes -
            Symptom Severity Original: Minor [ 14432 ] New: Severity 3 - Minor [ 15832 ]
            Patricio made changes -
            Comment [ A comment with security level 'atlassian-staff' was removed. ]
            Alexey Chystoprudov made changes -
            Link Original: This issue relates to BAM-12161 [ BAM-12161 ]
            Przemek Bruski made changes -
            Resolution New: Duplicate [ 3 ]
            Status Original: Open [ 1 ] New: Resolved [ 5 ]
            Przemek Bruski made changes -
            Link New: This issue duplicates BAM-12161 [ BAM-12161 ]
            Bugfix Automation Bot made changes -
            UIS Original: 10 New: 15
            Jeyanthan I (Inactive) made changes -
            Link New: This issue relates to BAM-12161 [ BAM-12161 ]

              Unassigned Unassigned
              mknight@atlassian.com Michael Knight
              Affected customers:
              55 This affects my team
              Watchers:
              56 Start watching this issue

                Created:
                Updated:
                Resolved: