public abstract class DataBoundTokenMacro extends TokenMacro
TokenMacro
that does parameter databinding to fields.
When you define your token macro as a subtype of this class, a fresh instance is created for each
evaluation, and fields or setters with the DataBoundTokenMacro.Parameter
annotation will receive the corresponding
parameter values, then the evaluate(AbstractBuild, TaskListener, String)
method gets invoked.
In this way, you simplify the parameter parsing and type conversion overhead.
Modifier and Type | Class and Description |
---|---|
static interface |
DataBoundTokenMacro.Parameter |
Constructor and Description |
---|
DataBoundTokenMacro() |
Modifier and Type | Method and Description |
---|---|
abstract String |
evaluate(hudson.model.AbstractBuild<?,?> context,
hudson.model.TaskListener listener,
String macroName) |
String |
evaluate(hudson.model.AbstractBuild<?,?> build,
hudson.model.TaskListener listener,
String macroName,
Map<String,String> arguments,
com.google.common.collect.ListMultimap<String,String> argumentMultimap)
Evaluates the macro and produces the token.
|
String |
evaluate(hudson.model.Run<?,?> run,
hudson.FilePath workspace,
hudson.model.TaskListener listener,
String macroName) |
String |
evaluate(hudson.model.Run<?,?> run,
hudson.FilePath workspace,
hudson.model.TaskListener listener,
String macroName,
Map<String,String> arguments,
com.google.common.collect.ListMultimap<String,String> argumentMultimap) |
boolean |
hasNestedContent()
Returns true if this object allows for nested content replacements.
|
acceptsMacroName, all, expand, expand, expand, expand, expandAll, expandAll, expandAll, expandAll, getAcceptedMacroNames, getAutoCompleteList, getPreviousRun, getWorkspace
public String evaluate(hudson.model.AbstractBuild<?,?> build, hudson.model.TaskListener listener, String macroName, Map<String,String> arguments, com.google.common.collect.ListMultimap<String,String> argumentMultimap) throws MacroEvaluationException, IOException, InterruptedException
TokenMacro
If the token is to produce a human readable text, it should do so by using the implicit locale associated
with the calling thread — see Functions.getCurrentLocale()
.
evaluate
in class TokenMacro
build
- The build object for which this macro is evaluated.listener
- If the progress/status needs to be reported to the build console output, this object can be used.macroName
- The macro name that you acceptedarguments
- Arguments as a map. If multiple values are specified for one key, this will only retain the last one.
This is passed in separately from argumentMultimap
becauseargumentMultimap
- The same arguments, but in a multi-map. If multiple values are specified for one key, all of them
are retained here in the order of appearance. For those macros that support multiple values for the same key
this is more accurate than arguments
, but it's bit more tedious to use.MacroEvaluationException
- If the evaluation failed, for example because of the parameter error, and that the error message
should be presented.IOException
- Other fatal IOException
s that should leave the stack trace in the console.InterruptedException
- If the evaluation involves some remoting operation, user might cancel the build, which results
in an InterruptedException
. Don't catch it, just propagate.public String evaluate(hudson.model.Run<?,?> run, hudson.FilePath workspace, hudson.model.TaskListener listener, String macroName, Map<String,String> arguments, com.google.common.collect.ListMultimap<String,String> argumentMultimap) throws MacroEvaluationException, IOException, InterruptedException
evaluate
in class TokenMacro
MacroEvaluationException
IOException
InterruptedException
public abstract String evaluate(hudson.model.AbstractBuild<?,?> context, hudson.model.TaskListener listener, String macroName) throws MacroEvaluationException, IOException, InterruptedException
public String evaluate(hudson.model.Run<?,?> run, hudson.FilePath workspace, hudson.model.TaskListener listener, String macroName) throws MacroEvaluationException, IOException, InterruptedException
public boolean hasNestedContent()
TokenMacro
hasNestedContent
in class TokenMacro
TokenMacro.expand(AbstractBuild, TaskListener, String)
for additional expansion.Copyright © 2016–2021. All rights reserved.