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

Builds are not getting triggered when changes include a Specs update and there are multiple Specs repositories with at least one that doesn't have permissions to modify the plan

    XMLWordPrintable

Details

    Description

      Issue Summary

      Builds are not getting triggered when changes include a Specs update and there are multiple Specs repositories (Bitbucket Server or Data Center) with at least one that doesn't have permissions to modify the project that the plan belongs to.

      This is reproducible on Data Center: Yes.

      Steps to Reproduce

      Note

      Make sure Bamboo and Bitbucket are linked together through an application link before continuing.

      1. Create a Bitbucket (Server or Data Center) repository (e.g. myRepo).
      2. Create a linked repository in Bamboo pointing to the repository created in the previous step (e.g. repo1).
        • Enable Bamboo Specs in the repository configuration and give it the following access Project creation allowed, Access all projects and Access all repositories.
      3. Create a project in Bamboo named Test with key TEST.
      4. Create a bamboo-specs folder inside your repository's root and the bamboo.yaml file inside with the following content:
        <repository-root>/bamboo-specs/bamboo.yaml
        ---
        version: 2
        plan:
          project-key: TEST
          key: PLAN
          name: Plan
        stages:
        - Default Stage:
            manual: false
            final: false
            jobs:
            - Default Job
        Default Job:
          key: JOB1
          tasks:
          - checkout:
              force-clean-build: 'false'
              description: Checkout Default Repository
          artifact-subscriptions: []
        repositories:
        - yourRepositoryNameHere:
            scope: global
        branches:
          create: for-new-branch
          delete: never
          link-to-jira: false
        notifications: []
        labels: []
        dependencies:
          require-all-stages-passing: false
          enabled-for-branches: true
          block-strategy: none
          plans: []
        other:
          concurrent-build-plugin: system-default
        

        Replace the yourRepositoryNameHere in the YAML file above with the name of your linked repository created in step 2 otherwise the Specs import will fail.

      5. This will create a plan called Plan under the Test project. You should see one Specs update and one build triggered for TEST-PLAN at this stage.
      6. Now create another linked repository in Bamboo pointing to the same repository created in the first step (e.g. repo2).
        • Enable Bamboo Specs in the repository configuration but DO NOT give it any access.
      7. At this stage you have two linked repositories pointing to the same Bitbucket (Server or Data Center) repository and with Specs enabled with the exception that one has access to TEST-PLAN (i.e. repo1) and the other doesn't (i.e. repo2).
      8. Go back to your repository and update the force-clean-build attribute in the YAML file to true.
      9. Create a test file inside the repository root (e.g. hello-world.txt) with some random content. For example:
        echo test > hello-world.txt
        
      10. Git add, commit and push both changes to Bitbucket.

      Expected Results

      The first repository created in the second step (e.g. repo1) should be capable of parsing the Specs change and update the plan as well as trigger a build. The second repository created in step 6 (e.g. repo2) should fail since it doesn't have access to the project that the plan belongs to.

      Actual Results

      The first repository created in the second step (e.g. repo1) is capable of parsing the Specs change and update the plan but it does not trigger a build. The second repository created in step 6 (e.g. repo2) fails since it doesn't have access to the project that the plan belongs to. The problem here is that no builds are triggered.

      The below exception is thrown in the <bamboo-home>/logs/atlassian-bamboo.log file:

      2022-05-31 09:47:40,594 INFO [15-BAM::SpecsDetection:pool-18-thread-4] [YamlSpecsImportServiceImpl] Bamboo YAML import failed on incorrect YAML
      com.atlassian.bamboo.specs.yaml.YamlSpecsValidationException: Repository "repo2" doesn't have access to project "Test" (TEST)
      	at com.atlassian.bamboo.configuration.external.yaml.BambooYamlValidatorImpl.validatePlan(BambooYamlValidatorImpl.java:86)
      	at com.atlassian.bamboo.configuration.external.rss.YamlSpecsImportServiceImpl.parseYaml(YamlSpecsImportServiceImpl.java:162)
      	at com.atlassian.bamboo.configuration.external.rss.YamlSpecsImportServiceImpl.processSimplifiedYaml(YamlSpecsImportServiceImpl.java:107)
      	at com.atlassian.bamboo.configuration.external.RepositoryStoredSpecsServiceImpl.tryProcessYaml(RepositoryStoredSpecsServiceImpl.java:338)
      	at com.atlassian.bamboo.configuration.external.RepositoryStoredSpecsServiceImpl.runBambooSpecs(RepositoryStoredSpecsServiceImpl.java:184)
      	at com.atlassian.bamboo.configuration.external.RssDetectionServiceImpl.runRssDetection(RssDetectionServiceImpl.java:374)
      	at com.atlassian.bamboo.configuration.external.detection.RssDetectionRunnable.run(RssDetectionRunnable.java:42)
      	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      	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.base/java.lang.Thread.run(Thread.java:829)
      2022-05-31 09:47:40,604 INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-52] [BitbucketServerRssStatusUpdater] Sending RSS notification to Stash (repository: repo2)
      2022-05-31 09:47:40,607 INFO [15-BAM::SpecsDetection:pool-18-thread-4] [RssDetectionRunnable] Exception while executing RSS detection for RssDetectionWork[repository=950275,branch=main]
      com.atlassian.bamboo.specs.yaml.YamlSpecsValidationException: Repository "repo2" doesn't have access to project "Test" (TEST)
      	at com.atlassian.bamboo.configuration.external.yaml.BambooYamlValidatorImpl.validatePlan(BambooYamlValidatorImpl.java:86)
      	at com.atlassian.bamboo.configuration.external.rss.YamlSpecsImportServiceImpl.parseYaml(YamlSpecsImportServiceImpl.java:162)
      	at com.atlassian.bamboo.configuration.external.rss.YamlSpecsImportServiceImpl.processSimplifiedYaml(YamlSpecsImportServiceImpl.java:107)
      	at com.atlassian.bamboo.configuration.external.RepositoryStoredSpecsServiceImpl.tryProcessYaml(RepositoryStoredSpecsServiceImpl.java:338)
      	at com.atlassian.bamboo.configuration.external.RepositoryStoredSpecsServiceImpl.runBambooSpecs(RepositoryStoredSpecsServiceImpl.java:184)
      	at com.atlassian.bamboo.configuration.external.RssDetectionServiceImpl.runRssDetection(RssDetectionServiceImpl.java:374)
      	at com.atlassian.bamboo.configuration.external.detection.RssDetectionRunnable.run(RssDetectionRunnable.java:42)
      	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      	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.base/java.lang.Thread.run(Thread.java:829)
      2022-05-31 09:47:40,611 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-40] [AsynchronousAbleEventDispatcher] There was an exception thrown trying to dispatch event [com.atlassian.stash.plugin.remote.event.StashBranchChangedRemoteEvent@51c6b81d[branchName=main,committer=admin,repositoryProject=project,repositorySlug=repo,sourceId=78617614-a311-3f5e-8abf-d295d83ec90f,sourceUrl=https://mybitbucket.com/bitbucket]] from the invoker [com.atlassian.event.internal.ComparableListenerInvoker@781771d]
      java.lang.RuntimeException: Repository "repo2" doesn't have access to project "Test" (TEST). Listener: com.atlassian.bamboo.plugins.stash.events.BranchChangedEventListener event: com.atlassian.stash.plugin.remote.event.StashBranchChangedRemoteEvent
      	at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:53)
      	at com.atlassian.event.internal.ComparableListenerInvoker.invoke(ComparableListenerInvoker.java:48)
      	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.lambda$null$0(AsynchronousAbleEventDispatcher.java:37)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      	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.base/java.lang.Thread.run(Thread.java:829)
      Caused by: com.atlassian.bamboo.specs.yaml.YamlSpecsValidationException: Repository "repo2" doesn't have access to project "Test" (TEST)
      	at com.atlassian.bamboo.configuration.external.yaml.BambooYamlValidatorImpl.validatePlan(BambooYamlValidatorImpl.java:86)
      	at com.atlassian.bamboo.configuration.external.rss.YamlSpecsImportServiceImpl.parseYaml(YamlSpecsImportServiceImpl.java:162)
      	at com.atlassian.bamboo.configuration.external.rss.YamlSpecsImportServiceImpl.processSimplifiedYaml(YamlSpecsImportServiceImpl.java:107)
      	at com.atlassian.bamboo.configuration.external.RepositoryStoredSpecsServiceImpl.tryProcessYaml(RepositoryStoredSpecsServiceImpl.java:338)
      	at com.atlassian.bamboo.configuration.external.RepositoryStoredSpecsServiceImpl.runBambooSpecs(RepositoryStoredSpecsServiceImpl.java:184)
      	at com.atlassian.bamboo.configuration.external.RssDetectionServiceImpl.runRssDetection(RssDetectionServiceImpl.java:374)
      	at com.atlassian.bamboo.configuration.external.detection.RssDetectionRunnable.run(RssDetectionRunnable.java:42)
      	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      	... 7 more
      

      What's interesting in this case is that when there's no Specs change (no step 8, only step 9) Bamboo is capable of triggering the build. When the change made in Bitbucket (Server or Data Center) includes both Specs update and any other change made in the repository Bamboo throws the exception above and doesn't trigger a build (it updates the Specs configuration though because of repo1).

      Workaround

      The only solution to this problem is to either a) remove the "duplicate" linked repository in Bamboo that has Specs enabled but doesn't have permission on the project, b) grant the "duplicate" repository access to the project or c) disable Specs for the "duplicate" repository.

      Ideally, and as a best practice, you should not have multiple linked repositories with Bamboo Specs enabled and pointing to the same Bitbucket (Server or Data Center) repository. Unfortunately there's currently no way to enforce/ prevent that from happening in Bamboo.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              brosa Bruno Rosa
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: