Interface PrePostTaskActions

  • All Superinterfaces:
    BambooPluginModule

    @ExperimentalApi
    public interface PrePostTaskActions
    extends BambooPluginModule
    Custom actions that run before and after a build task (TaskType), a deployment task (com.atlassian.bamboo.deployments.execution.DeploymentTaskType, or a common task (CommonTaskType) in a build or a deployment plan. This actions object will be handled by a task executor as stateful, which means that the same instance will be used to call executeBefore and executeAfter methods. Thanks to this, you can store some data in executeBefore and use it in executeAfter.
    Since:
    5.7
    • Method Detail

      • executeBefore

        void executeBefore​(@NotNull
                           @NotNull InternalTaskType task,
                           @NotNull
                           @NotNull CommonTaskContext context)
                    throws Exception
        Executes a custom action before the task is executed.
        Parameters:
        task - a current task, it can be actually a subclass of TaskType (build plans), DeploymentTaskType (deployment plans) or CommonTaskType (build or deployment plans)
        context - a current task context, can be actually a TaskContext (build plans) or DeploymentTaskContext (deployment plans), TODO can it be a CommonTaskContext? flow in TaskExecutorImpl suggests that it may happen - but under which conditions actually?
        Throws:
        Exception - in case when a pre-task action fails
      • executeAfter

        TaskResult executeAfter​(@NotNull
                                @NotNull InternalTaskType task,
                                @Nullable
                                @Nullable TaskResult taskResult)
                         throws Exception
        Executes a custom action after the task is executed.
        Parameters:
        task - a current task which was executed
        taskResult - a result of a task execution; may be null in case task terminated abnormally
        Returns:
        TaskResult a result of a task execution (you may return the original result or modify it)
        Throws:
        Exception - in case when a post-task action fails