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

Plan branch creation on pull request with use of plan repository in Bamboo Java Spec fails

XMLWordPrintable

      Issue Summary

      Without changing anything on the Java Specs, but just in the source, new plan branches are created on each pull request (PR) and the build is correctly triggered.

      However, on a syntactically correct change and commit of the Bamboo Specs defining this plan, a subsequent repository scan fails.

      Bamboo: 6.7.2 and 6.10.4

      Bitbucket Server (BBS): 7.3.0 with a separate Source Code repository and a Bamboo Specs repository

      Steps to Reproduce

      1. Create a PlanSpec.java so that it's spinning up your Bamboo plan, like so:
        @BambooSpec
        public class PlanSpec {
            
            public Plan plan() {
                final Plan plan = new Plan(new Project()
                        .key(new BambooKey("PBPR"))
                        .name("PlanBranch-PR"),
                    "PlanBranch-and-PR-planReop-JavaSpecs-1",
                    new BambooKey("JAJA"))
                    .description("Use plan repository for source code")
                    .pluginConfigurations(new ConcurrentBuilds()
                            .useSystemWideDefault(false)
                            .maximumNumberOfConcurrentBuilds(3))
                    .stages(new Stage("Default Stage")
                            .jobs(new Job("Default Job",
                                    new BambooKey("JOB1"))
                                    .tasks(new VcsCheckoutTask()
                                            .description("Checkout Default Repository")
                                            .checkoutItems(new CheckoutItem().defaultRepository()),
                                        new ScriptTask()
                                            .description("Print out content of working directory")
                                            .inlineBody("ls -al ${bamboo.build.working.directory}"))
                                    .finalTasks(new CleanWorkingDirectoryTask()
                                            .description("Clean me up!"))))
                    .planRepositories(new BitbucketServerRepository()
                            .name("New plan BB C source repo")
                            .repositoryViewer(new BitbucketServerRepositoryViewer())
                            .server(new ApplicationLink()
                                    .name("Bitbucket")
                                    .id("e428c969-cc66-3e2d-ae7e-30171ed766ab"))
                            .projectKey("TEST")
                            .repositorySlug("c-source")
                            .sshPublicKey("...")
                            .sshPrivateKey("...")
                            .sshCloneUrl("ssh://git@localhost:7999/test/c-source.git")
                            .verboseLogs(true)
                            .fetchWholeRepository(true)
                            .changeDetection(new VcsChangeDetection()))
                    
                    .triggers(new BitbucketServerTrigger())
                    .planBranchManagement(new PlanBranchManagement()
                            .createForPullRequest()
                            .delete(new BranchCleanup()
                                .whenRemovedFromRepositoryAfterDays(7)
                                .whenInactiveInRepositoryAfterDays(30))
                            .notificationForCommitters()
                            .issueLinkingEnabled(false));
                return plan;
            }
            
            public PlanPermissions planPermission() {
                final PlanPermissions planPermission = new PlanPermissions(new PlanIdentifier("PBPR", "JAJA"))
                    .permissions(new Permissions()
                            .userPermissions("bamboo", PermissionType.ADMIN, PermissionType.VIEW, PermissionType.CLONE, PermissionType.BUILD, PermissionType.EDIT));
                return planPermission;
            }
        
      2. Use this plan in order to verify that it is working without any change to its Bamboo Specs
        • Create a new branch in your Git Source Code repository (e.g. per "Edit" directly in BBS UI), then change any of its files and save it
        • Perform git add and git commit (or from BBS UI "Commit") and push the change back to central (automatic in BBS, explicit on command-line)
        • Next create a pull request PR (e.g. pull from this new branch to master)
        • This PR will create a new plan branch in Bamboo and automatically run the build there
          (you may vary these 4 steps and repeat them a s often as wished, they will always succeed)
      3. Next navigate to the Bamboo Java Specs repository in BBS, open file PlanSpec.java from above, perform a simpe change like modification of the plan's description (but could be any) and save this change
      4. Commit this change in BBS UI or git add, git commit and git push from command-line. That triggers the Bamboo Java Specs being scanned.
      5. This scanning process fails (see error message below). Thus this plan change cannot get applied and Bamboo indicated "Specs configuratin update" error in red.
      6. By that, this plan is automatically disabled. You can select "Enable plan" as a select option under the "Actions" button and continue performing changes, committing and pushing those to your Source Code repository asdescribed in step 2 and that works as before (though, on base of the unchanged plan configuration only).

      Expected Results

      Bamboo Java Specs update works fine, thus Specs scan succeeds and Specs changes are applied.

      Actual Results

      No changes are applied and plan defined by Specs code gets disabled.

      The below exception is thrown on repository scan:

      com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException: Plan branch / workflow: You can't change the default repository because automatic branch management for this plan is dependent on pull request  and PR plan branches exist for this build.Update plan's branching configuration or delete existing pull request plans to enable switching the default repository.
      java.lang.IllegalArgumentException: com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException: Plan branch / workflow: You can't change the default repository because automatic branch management for this plan is dependent on pull request  and PR plan branches exist for this build.Update plan's branching configuration or delete existing pull request plans to enable switching the default repository.
      
      ...
      
      com.atlassian.bamboo.configuration.external.RepositoryStoredSpecsServiceImpl.importBambooYamlsOfAllTypes(RepositoryStoredSpecsServiceImpl.java:621)
      	at com.atlassian.bamboo.configuration.external.RepositoryStoredSpecsServiceImpl.processSpecs(RepositoryStoredSpecsServiceImpl.java:397)
      	at com.atlassian.bamboo.configuration.external.RepositoryStoredSpecsServiceImpl.runBambooSpecs(RepositoryStoredSpecsServiceImpl.java:279)
      	at com.atlassian.bamboo.configuration.external.RssDetectionServiceImpl.runRssDetection(RssDetectionServiceImpl.java:262)
      	at com.atlassian.bamboo.configuration.external.detection.RssDetectionRunnable.run(RssDetectionRunnable.java:42)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48)
      	at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)
      	at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)
      	at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException: Plan branch / workflow: You can't change the default repository because automatic branch management for this plan is dependent on pull request  and PR plan branches exist for this build.Update plan's branching configuration or delete existing pull request plans to enable switching the default repository.
      

      Workaround

      1. Set up a new build plan from scratch using the changed Bamboo Java Specs (per changing the plan name, you may conserve your recent plan and thus not lose previously created plan branches and its results).
      2. Using Linked repository like so .linkedRepositories() for Source Code repository in  Bamboo Java Specs instead of plan repository avoids this issue to happen. Therefore, you may consider consequently using Linked repositories instead.

              mgardias Marcin Gardias
              gforster@atlassian.com Gerhard Forster (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: