Package com.atlassian.bitbucket.scm
Interface CommandBuilderSupport<B extends CommandBuilderSupport<B>>
- All Known Subinterfaces:
CommandBuilder<B>,ScmCommandBuilder<B>
@NotThreadSafe
public interface CommandBuilderSupport<B extends CommandBuilderSupport<B>>
Provides a unifying abstraction for common functionality expected to be provided by both free-form
CommandBuilders and, for those plugins which choose to provide them, type-safe builders.-
Method Summary
Modifier and TypeMethodDescription<T> Command<T>build(CommandOutputHandler<T> outputHandler) Clears any environment variables which have been set.Applies the defaultCommandExitHandler.exitHandler(CommandExitHandler value) Sets theCommandExitHandlerwhich should be invoked after the command exits.removeEnvironment(String name) Removes the environment variable with the providednameif it has been setwithEnvironment(String name, String value) Adds an environment variable with the specifiednameandvalue.
-
Method Details
-
build
Builds aCommandwhich, whenexecuted, will provide output to the providedoutputHandlerfor processing.- Type Parameters:
T- type for the builder- Parameters:
outputHandler- the handler to receive and process output from the command as it executes- Returns:
- the built command
- Throws:
NullPointerException- if the providedoutputHandlerisnull
-
clearEnvironment
Clears any environment variables which have been set.- Returns:
this
-
defaultExitHandler
Applies the defaultCommandExitHandler. The default exit handler used is based on the builder in play; each builder is free to define its own default exit handler.Note: If no explicit exit handler
is set, the default will be applied automatically when the command isbuilt; it is not possible to build a command without an exit handler.- Returns:
this
-
exitHandler
Sets theCommandExitHandlerwhich should be invoked after the command exits. This handler receives:- the exit code from the process
- any
Throwablethrown during processing - any output the process wrote to its error stream
- Parameters:
value- the handler which should be invoked when the command exits- Returns:
this- Throws:
NullPointerException- if the providedvalueisnull
-
removeEnvironment
Removes the environment variable with the providednameif it has been set- Parameters:
name- the name of the environment variable to clear- Returns:
this- Throws:
IllegalArgumentException- ifnameis empty or blankNullPointerException- ifnameisnull- Since:
- 5.12
-
withEnvironment
Adds an environment variable with the specifiednameandvalue. Both parameters are required, and an exception will be thrown if either is not provided.- Parameters:
name- the name of the environment variable to setvalue- the value to set for the environment variable- Returns:
this- Throws:
IllegalArgumentException- ifnameorvalueis empty or blankNullPointerException- ifnameorvalueisnull- Since:
- 4.8
-