Class TaskResultBuilder


  • @PublicApi
    public class TaskResultBuilder
    extends Object
    Evaluates the execution of TaskTypes to produce a TaskResult
    Since:
    3.1
    • Method Detail

      • copyWithNewState

        public static TaskResult copyWithNewState​(@NotNull
                                                  @NotNull TaskResult taskResult,
                                                  @NotNull
                                                  @NotNull TaskState newTaskState)
        Copies a taskResult and changes the state
        Parameters:
        taskResult - to copy
        newTaskState - to replace the old taskState
        Returns:
        the new TaskResult
      • createFailedWithErrorResult

        public static TaskResult createFailedWithErrorResult​(TaskIdentifier taskIdentifier)
        Method to create error result bypassing the builder. Infrastructure related failures may not have a taskContext.
        Parameters:
        taskIdentifier - identifying the task that failed
        Returns:
        TaskResult.
      • failedWithError

        public TaskResultBuilder failedWithError()
        Sets the Task Result Status as TaskState.ERROR
        Returns:
        the current TaskResultBuilder with updated status
      • checkReturnCode

        public TaskResultBuilder checkReturnCode​(@NotNull
                                                 @NotNull com.atlassian.utils.process.ExternalProcess externalProcess)
        Checks that the return code of the ExternalProcess was zero Will only check return codes if the build state has not been set to Failed for some other reason.
        Parameters:
        externalProcess - - to check return code of
        Returns:
        the current TaskResultBuilder with updated status based on the return code
      • checkReturnCode

        public TaskResultBuilder checkReturnCode​(@NotNull
                                                 @NotNull com.atlassian.utils.process.ExternalProcess externalProcess,
                                                 int expectedReturnCode)
        Checks that the return code of the ExternalProcess was of the expected type. Will only check return codes if the build state has not been set to Failed for some other reason.
        Parameters:
        externalProcess - - process to check return code from
        expectedReturnCode - - the return code to be considered a success.
        Returns:
        the current TaskResultBuilder with updated status based on the return code
      • checkTestFailures

        public TaskResultBuilder checkTestFailures()
        Checks whether any test failures have been recorded against the buildResult and updates the state accordingly Will only check tests if the build state has not been set to Failed for some other reason.
        Returns:
        the current TaskResultBuilder with updated status based on the test outcome
      • getTaskState

        public TaskState getTaskState()
      • stopJobExecutionAfterTask

        public TaskResultBuilder stopJobExecutionAfterTask()
        stop job execution after this task result processing