Class RunSelectorContext
java.lang.Object
org.jenkinsci.plugins.runselector.context.RunSelectorContext
- All Implemented Interfaces:
Cloneable
Context for an execution of runselector.
This allows us to adding new fields without affecting existing plugins.
You can manage plugin specific information using
addExtension(Object) and getExtension(Class).
-
Constructor Summary
ConstructorsConstructorDescriptionRunSelectorContext(Jenkins jenkins, Run<?, ?> build, TaskListener listener) Creates a newRunSelectorContextwithNoRunFilter.RunSelectorContext(Jenkins jenkins, Run<?, ?> build, TaskListener listener, RunFilter runFilter) Creates a newRunSelectorContext. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExtension(Object extension) Add an object to hold plugin specific information.clone()Run<?, ?> getBuild()Shortcut forgetListener().getLogger()<T> TgetExtension(Class<T> clazz) Extract an extension object of the specified class.Run<?, ?> The build picked at the last time (but not matched with the filter).booleanvoidOutputs a log message ifisVerbose()istruevoidvoidlogException(String string, Throwable t) Outputs a log message with an exceptionvoidOutputs a log messagevoidOutputs a log message inMessageFormatformats.booleanremoveExtension(Object extension) booleanreplaceExtension(Object extension) Removes extensions with the same class type before adding.voidsetLastMatchBuild(Run<?, ?> lastMatchBuild) voidsetRunFilter(RunFilter runFilter) voidsetVerbose(boolean verbose)
-
Constructor Details
-
RunSelectorContext
public RunSelectorContext(@NonNull Jenkins jenkins, @NonNull Run<?, ?> build, @NonNull TaskListener listener) throws IOException, InterruptedExceptionCreates a newRunSelectorContextwithNoRunFilter.- Parameters:
jenkins- the Jenkins instancebuild- the build running runselectorlistener- listener for the build running runselector- Throws:
IOExceptionInterruptedException
-
RunSelectorContext
public RunSelectorContext(@NonNull Jenkins jenkins, @NonNull Run<?, ?> build, @NonNull TaskListener listener, @NonNull RunFilter runFilter) throws IOException, InterruptedExceptionCreates a newRunSelectorContext.- Parameters:
jenkins- the Jenkins instancebuild- the build running runselectorlistener- listener for the build running runselector- Throws:
IOExceptionInterruptedException
-
-
Method Details
-
getJenkins
- Returns:
- the Jenkins instance
-
getBuild
- Returns:
- the build running runselector
-
getListener
- Returns:
- the listener for the build running runselector
-
getEnvVars
- Returns:
- environment variables for the current build
-
getConsole
Shortcut forgetListener().getLogger()- Returns:
- stream to output logs
-
setVerbose
public void setVerbose(boolean verbose) - Parameters:
verbose- whether output verbose (for diagnostics) logs
-
isVerbose
public boolean isVerbose()- Returns:
- whether output verbose (for diagnostics) logs
-
setRunFilter
- Parameters:
runFilter- the filter for builds
-
getRunFilter
- Returns:
- a filter for builds
-
setLastMatchBuild
- Parameters:
lastMatchBuild- build picked at the last time
-
getLastMatchBuild
The build picked at the last time (but not matched with the filter).RunSelectors should continue the enumeration from this.- Returns:
- build picked at the last time
-
getExtensionList
- Returns:
- additional information by plugins
-
addExtension
Add an object to hold plugin specific information.- Parameters:
extension- extension object
-
removeExtension
- Parameters:
extension- extension object to remove- Returns:
- true if the extension is contained
-
replaceExtension
Removes extensions with the same class type before adding.- Parameters:
extension- extension object to replace with- Returns:
- true if an extension object of the same class class is contained
-
getExtension
Extract an extension object of the specified class.- Type Parameters:
T- specified withclazz- Parameters:
clazz- class of the extension to extract- Returns:
- extension of the class
-
logInfo
Outputs a log message- Parameters:
message- message to log
-
logInfo
Outputs a log message inMessageFormatformats.- Parameters:
pattern- pattern forMessageFormatarguments- values to format
-
logDebug
Outputs a log message ifisVerbose()istrue- Parameters:
message- message to log
-
logDebug
- Parameters:
pattern- pattern forMessageFormatarguments- values to format
-
logException
Outputs a log message with an exception- Parameters:
string- message to logt- exception to log
-
clone
-