Interface LightweightBranchCreationService

    • Method Detail

      • createOrEnableChainBranch

        @NotNull
        @NotNull ChainBranchCreationResult createOrEnableChainBranch​(@NotNull
                                                                     @NotNull ImmutableChain chain,
                                                                     @NotNull
                                                                     @NotNull PlanBranchWorkflow planBranchWorkflow,
                                                                     @Nullable
                                                                     @Nullable String branchName,
                                                                     @NotNull
                                                                     @NotNull Function<VcsBranchConfigurator,​VcsBranch> vcsBranchProvider,
                                                                     @Nullable
                                                                     @Nullable BuildConfiguration buildConfiguration,
                                                                     @NotNull
                                                                     PlanCreationService.EnablePlan enablePlan,
                                                                     boolean enableExpiry,
                                                                     @NotNull
                                                                     @NotNull Consumer<PlanKey> branchPlanKeyConsumer,
                                                                     boolean expectingDivergentBranch)
                                                              throws PlanCreationDeniedException
        Given a branch name and (optionally) vcs branch name, check if branch already exists. If it does, enable it if it's disabled. Otherwise create a new lightweight plan branch.
        Parameters:
        chain - to create branch under
        planBranchWorkflow - which workflow led to creation of branch
        branchName - optional name for the plan branch. If null name of vcs branch will be used
        vcsBranchProvider - provides VcsBranch to use when overriding repository definition
        buildConfiguration - optional default fragment of configuration to create the chain branch with
        enablePlan - defines whether newly created branches should be enabled or disabled after creation
        enableExpiry - defines whether created branch can be removed due to branch expiration detection
        branchPlanKeyConsumer - code should be executed before triggering events that new plan created
        expectingDivergentBranch - RSS will attempt updating this branch; post creation events should be deferred
        Returns:
        key of the created plan branch
        Throws:
        PlanCreationDeniedException
      • createOrEnableChainBranch

        @NotNull
        @NotNull ChainBranchCreationResult createOrEnableChainBranch​(@NotNull
                                                                     @NotNull ImmutableChain chain,
                                                                     @NotNull
                                                                     @NotNull PlanBranchWorkflow planBranchWorkflow,
                                                                     @Nullable
                                                                     @Nullable String branchName,
                                                                     @NotNull
                                                                     @NotNull Function<VcsBranchConfigurator,​VcsBranch> vcsBranchProvider,
                                                                     @Nullable
                                                                     @Nullable BuildConfiguration buildConfiguration,
                                                                     @NotNull
                                                                     PlanCreationService.EnablePlan enablePlan,
                                                                     boolean enableExpiry,
                                                                     @NotNull
                                                                     @NotNull Consumer<PlanKey> branchPlanKeyConsumer,
                                                                     boolean expectingDivergentBranch,
                                                                     Optional<VcsPullRequest> pullRequest)
                                                              throws PlanCreationDeniedException
        Given a branch name and (optionally) vcs branch name, check if branch already exists. If it does, enable it if it's disabled. Otherwise create a new lightweight plan branch. The overloaded method is aimed to deal with pull requests.
        Parameters:
        chain - to create branch under
        planBranchWorkflow - which workflow led to creation of branch
        branchName - optional name for the plan branch. If null name of vcs branch will be used
        vcsBranchProvider - provides VcsBranch to use when overriding repository definition
        buildConfiguration - optional default fragment of configuration to create the chain branch with
        enablePlan - defines whether newly created branches should be enabled or disabled after creation
        enableExpiry - defines whether created branch can be removed due to branch expiration detection
        branchPlanKeyConsumer - code should be executed before triggering events that new plan created
        expectingDivergentBranch - RSS will attempt updating this branch; post creation events should be deferred
        pullRequest - optional pull requests object which contains potential source repository information
        Returns:
        key of the created plan branch
        Throws:
        PlanCreationDeniedException
      • createChainBranches

        @NotNull
        @NotNull Collection<ChainBranchCreationResult> createChainBranches​(@NotNull
                                                                           @NotNull ImmutableChain chain,
                                                                           @NotNull
                                                                           @NotNull PlanBranchWorkflow planBranchWorkflow,
                                                                           @NotNull
                                                                           @NotNull Collection<VcsBranch> branches,
                                                                           @NotNull
                                                                           @NotNull PlanRepositoryDefinition defaultRepositoryDefinition,
                                                                           @Nullable
                                                                           @Nullable ErrorCollection errorCollection,
                                                                           @NotNull
                                                                           PlanCreationService.EnablePlan enablePlan,
                                                                           boolean enableExpiry,
                                                                           @NotNull
                                                                           @NotNull Consumer<PlanKey> branchPlanKeyConsumer,
                                                                           boolean expectingDivergentBranch)
        Creates a new lightweight plan branch or enables existing one for each vcs branch in given collection under given chain.
        Parameters:
        chain - to create branches under
        planBranchWorkflow - which workflow led to creation of these branches
        branches - collection ov vcs branches for which plan branches should be created
        defaultRepositoryDefinition - default repository of the given chain
        errorCollection - to add errors to, if you don't supply an error collection, they will just get logged
        enablePlan - defines whether newly created branches should be enabled or disabled after creation
        enableExpiry - defines whether created branch can be removed due to branch expiration detection
        branchPlanKeyConsumer - code should be executed before triggering events that new plan created
        expectingDivergentBranch - RSS will attempt updating this branch; post creation events should be deferred
        Returns:
        keys of created plan branches
      • createChainBranch

        @NotNull
        @NotNull ChainBranchCreationResult createChainBranch​(@NotNull
                                                             @NotNull ImmutableChain chain,
                                                             @NotNull
                                                             @NotNull PlanBranchWorkflow planBranchWorkflow,
                                                             @NotNull
                                                             @NotNull String branchName,
                                                             @Nullable
                                                             @Nullable String branchDescription,
                                                             @Nullable
                                                             @Nullable PlanRepositoryDefinition defaultRepositoryDefinition,
                                                             @Nullable
                                                             @Nullable VcsRepositoryModuleDescriptor moduleDescriptor,
                                                             @Nullable
                                                             @Nullable VcsBranch newBranch,
                                                             @NotNull
                                                             @NotNull BuildConfiguration buildConfiguration,
                                                             PlanCreationService.EnablePlan enablePlan,
                                                             boolean enableExpiry,
                                                             @NotNull
                                                             @NotNull Consumer<PlanKey> branchPlanKeyConsumer,
                                                             boolean expectingDivergentBranch)
                                                      throws PlanCreationDeniedException
        Creates a new lightweight plan branch for give chain. Does not check if plan branch for given VCS branch already exists.
        Parameters:
        chain - to create branches under
        planBranchWorkflow - which workflow led to creation of branch
        branchName - optional plan branch name
        branchDescription - optional plan branch description
        defaultRepositoryDefinition - optional default repository of the given chain
        moduleDescriptor - module descriptor of the given defaultRepositoryDefinition
        newBranch - VCS branch to use
        buildConfiguration - optional default fragment of configuration to create the chain branch with
        enablePlan - defines whether newly created branches should be enabled or disabled after creation
        enableExpiry - defines whether created branch can be removed due to branch expiration detection
        branchPlanKeyConsumer - code should be executed before triggering events that new plan created
        expectingDivergentBranch - RSS will attempt updating this branch; post creation events should be deferred
        Returns:
        key of the created plan branch
        Throws:
        PlanCreationDeniedException
      • createChainBranch

        @NotNull
        @NotNull ChainBranchCreationResult createChainBranch​(@NotNull
                                                             @NotNull ImmutableChain chain,
                                                             @NotNull
                                                             @NotNull PlanBranchWorkflow planBranchWorkflow,
                                                             @NotNull
                                                             @NotNull String branchName,
                                                             @Nullable
                                                             @Nullable String branchDescription,
                                                             @Nullable
                                                             @Nullable PlanRepositoryDefinition defaultRepositoryDefinition,
                                                             @Nullable
                                                             @Nullable VcsRepositoryModuleDescriptor moduleDescriptor,
                                                             @Nullable
                                                             @Nullable VcsBranch newBranch,
                                                             @NotNull
                                                             @NotNull BuildConfiguration buildConfiguration,
                                                             PlanCreationService.EnablePlan enablePlan,
                                                             boolean enableExpiry,
                                                             @NotNull
                                                             @NotNull Consumer<PlanKey> branchPlanKeyConsumer,
                                                             boolean expectingDivergentBranch,
                                                             Optional<VcsPullRequest> pullRequest)
                                                      throws PlanCreationDeniedException
        Creates a new lightweight plan branch for give chain. Does not check if plan branch for given VCS branch already exists. The overloaded method is aimed to deal with pull requests.
        Parameters:
        chain - to create branches under
        planBranchWorkflow - which workflow led to creation of branch
        branchName - optional plan branch name
        branchDescription - optional plan branch description
        defaultRepositoryDefinition - optional default repository of the given chain
        moduleDescriptor - module descriptor of the given defaultRepositoryDefinition
        newBranch - VCS branch to use
        buildConfiguration - optional default fragment of configuration to create the chain branch with
        enablePlan - defines whether newly created branches should be enabled or disabled after creation
        enableExpiry - defines whether created branch can be removed due to branch expiration detection
        branchPlanKeyConsumer - code should be executed before triggering events that new plan created
        expectingDivergentBranch - RSS will attempt updating this branch; post creation events should be deferred
        pullRequest - optional pull requests object which contains potential source repository information
        Returns:
        key of the created plan branch
        Throws:
        PlanCreationDeniedException
      • validateCreateChainBranch

        void validateCreateChainBranch​(@NotNull
                                       @NotNull ImmutableChain chain,
                                       @NotNull
                                       @NotNull PlanBranchWorkflow planBranchWorkflow,
                                       @NotNull
                                       @NotNull String branchName,
                                       @Nullable
                                       @Nullable String branchDescription,
                                       @Nullable
                                       @Nullable PlanRepositoryDefinition defaultRepositoryDefinition,
                                       @Nullable
                                       @Nullable VcsRepositoryModuleDescriptor moduleDescriptor,
                                       @Nullable
                                       @Nullable VcsBranch newBranch,
                                       boolean enableExpiry,
                                       @NotNull
                                       @NotNull com.atlassian.struts.ValidationAware validationAware)
        Validates configuration for creating chain branch
        Parameters:
        chain - to create branches under
        planBranchWorkflow - which workflow led to creation of branch
        branchName - optional plan branch name
        branchDescription - optional plan branch description
        defaultRepositoryDefinition - optional default repository of the given chain
        moduleDescriptor - module descriptor of the given defaultRepositoryDefinition
        newBranch - VCS branch to use
        enableExpiry - defines whether created branch can be removed due to branch expiration * detection
        validationAware - to add errors to