Package com.atlassian.bamboo.task
Class TaskResultBuilder
- java.lang.Object
-
- com.atlassian.bamboo.task.TaskResultBuilder
-
@PublicApi public class TaskResultBuilder extends Object
Evaluates the execution ofTaskType
s to produce aTaskResult
- Since:
- 3.1
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description TaskResult
build()
TaskResultBuilder
checkInterceptorMatches(@NotNull ContentMatchingInterceptor interceptor, int maximumAge)
TaskResultBuilder
checkInterceptorNotMatches(@NotNull ContentMatchingInterceptor interceptor, int maximumAge)
TaskResultBuilder
checkReturnCode(@NotNull com.atlassian.utils.process.ExternalProcess externalProcess)
Checks that the return code of theExternalProcess
was zero Will only check return codes if the build state has not been set to Failed for some other reason.TaskResultBuilder
checkReturnCode(@NotNull com.atlassian.utils.process.ExternalProcess externalProcess, int expectedReturnCode)
Checks that the return code of theExternalProcess
was of the expected type.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.static TaskResult
copyWithNewState(@NotNull TaskResult taskResult, @NotNull TaskState newTaskState)
Copies a taskResult and changes the statestatic TaskResultBuilder
create(@NotNull TaskContext taskContext)
Deprecated.since 5.0 usenewBuilder(CommonTaskContext)
static TaskResult
createFailedWithErrorResult(TaskIdentifier taskIdentifier)
Method to create error result bypassing the builder.TaskResultBuilder
failed()
Sets the Task Result Status asTaskState.FAILED
TaskResultBuilder
failedWithError()
Sets the Task Result Status asTaskState.ERROR
TaskState
getTaskState()
static TaskResultBuilder
newBuilder(@NotNull CommonTaskContext taskContext)
Creates a new TaskResultBuilder for aCommonTaskContext
TaskResultBuilder
setState(TaskState taskState)
TaskResultBuilder
stopJobExecutionAfterTask()
stop job execution after this task result processingTaskResultBuilder
success()
Sets the Task Result Status asTaskState.SUCCESS
-
-
-
Method Detail
-
newBuilder
public static TaskResultBuilder newBuilder(@NotNull @NotNull CommonTaskContext taskContext)
Creates a new TaskResultBuilder for aCommonTaskContext
- Parameters:
taskContext
- of the executingTaskType
- Returns:
- evaluator
-
create
@Deprecated public static TaskResultBuilder create(@NotNull @NotNull TaskContext taskContext)
Deprecated.since 5.0 usenewBuilder(CommonTaskContext)
Creates a new TaskResultBuilder for aCommonTaskContext
- Parameters:
taskContext
- of the executingTaskType
- Returns:
- evaluator
-
copyWithNewState
public static TaskResult copyWithNewState(@NotNull @NotNull TaskResult taskResult, @NotNull @NotNull TaskState newTaskState)
Copies a taskResult and changes the state- Parameters:
taskResult
- to copynewTaskState
- 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.
-
success
public TaskResultBuilder success()
Sets the Task Result Status asTaskState.SUCCESS
- Returns:
- the current TaskResultBuilder with updated status
-
failed
public TaskResultBuilder failed()
Sets the Task Result Status asTaskState.FAILED
- Returns:
- the current TaskResultBuilder with updated status
-
failedWithError
public TaskResultBuilder failedWithError()
Sets the Task Result Status asTaskState.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 theExternalProcess
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 theExternalProcess
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 fromexpectedReturnCode
- - 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
-
checkInterceptorMatches
public TaskResultBuilder checkInterceptorMatches(@NotNull @NotNull ContentMatchingInterceptor interceptor, int maximumAge)
-
checkInterceptorNotMatches
public TaskResultBuilder checkInterceptorNotMatches(@NotNull @NotNull ContentMatchingInterceptor interceptor, int maximumAge)
-
build
public TaskResult build()
-
getTaskState
public TaskState getTaskState()
-
setState
public TaskResultBuilder setState(TaskState taskState)
-
stopJobExecutionAfterTask
public TaskResultBuilder stopJobExecutionAfterTask()
stop job execution after this task result processing
-
-