Class ArgumentsAction
- java.lang.Object
-
- org.jenkinsci.plugins.workflow.actions.ArgumentsAction
-
- All Implemented Interfaces:
Action
,ModelObject
,PersistentAction
public abstract class ArgumentsAction extends Object implements PersistentAction
Stores some or all of the arguments used to create and configure theStep
executed by aFlowNode
. This allows you to inspect information supplied in the pipeline script and otherwise discarded at runtime. Supplied argument values can be hidden and replaced with aArgumentsAction.NotStoredReason
for security or performance. Important note: these APIs do not provide recursive guarantees that returned datastructures are immutable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ArgumentsAction.NotStoredReason
Used as a placeholder marker forStep
arguments not stored for various reasons.
-
Field Summary
Fields Modifier and Type Field Description protected static int
MAX_RETAINED_LENGTH
Largest String, Collection, or array size we'll retain -- provides a rough size limit on any single field.
-
Constructor Summary
Constructors Constructor Description ArgumentsAction()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Map<String,Object>
getArguments()
Get the map of arguments used to instantiate theStep
, with aArgumentsAction.NotStoredReason
instead of the argument value supplied in the executed pipeline step if that value is filtered for size or security.static Map<String,Object>
getArguments(FlowNode n)
Get the map of arguments supplied to instantiate theStep
run in theFlowNode
given or empty if the arguments were not stored or the FlowNode was not a step.protected abstract Map<String,Object>
getArgumentsInternal()
Return a fast view of internal arguments, without creating immutable wrappersObject
getArgumentValue(String argumentName)
Get the value of a argument, or null if not present/not stored.Object
getArgumentValueOrReason(String argumentName)
Get the argument value or itsArgumentsAction.NotStoredReason
if it has been intentionally omitted.String
getDisplayName()
Map<String,Object>
getFilteredArguments()
Get just the fully stored, non-null arguments This means the arguments with allArgumentsAction.NotStoredReason
or null values removedstatic Map<String,Object>
getFilteredArguments(FlowNode n)
Get just the fully stored, non-null arguments This means the arguments with allArgumentsAction.NotStoredReason
or null values removedString
getIconFileName()
static Map<String,?>
getResolvedArguments(FlowNode n)
LikegetArguments(FlowNode)
but attempting to resolve actual classes.static String
getStepArgumentsAsString(FlowNode n)
Return a tidy string description for the step arguments, or null if none is present or we can't make one SeeStepDescriptor.argumentsToString(Map)
for the rulesString
getUrlName()
protected static boolean
isOversized(Object o)
Check for single oversized fields much likeisOversized(Object, int)
but usingMAX_RETAINED_LENGTH
.static boolean
isOversized(Object o, int maxElements)
Provides a basic check if an object contains any excessively large collection/array/string elements with more than maxElements in them.boolean
isUnmodifiedArguments()
Test ifStep
arguments are persisted in an unaltered form.
-
-
-
Method Detail
-
isOversized
public static boolean isOversized(@CheckForNull Object o, int maxElements)
Provides a basic check if an object contains any excessively large collection/array/string elements with more than maxElements in them. This is a trivial nonrecursive check, because implementations may need to do recursive operations to sanitize out secrets as well.- Parameters:
o
- Object to check, with null allowed since we may see null inputsmaxElements
- Max number of elements for a collection/map or characters in a string, or < 0 to ignore length rules.- Returns:
- True if object (or one of the contained objects) exceeds maxElements size.
-
isOversized
protected static boolean isOversized(@CheckForNull Object o)
Check for single oversized fields much likeisOversized(Object, int)
but usingMAX_RETAINED_LENGTH
.- Parameters:
o
- Object to check for being oversized or holding an oversized value.- Returns:
- True if object contains an oversized input, else false.
-
getIconFileName
public String getIconFileName()
- Specified by:
getIconFileName
in interfaceAction
-
getDisplayName
public String getDisplayName()
- Specified by:
getDisplayName
in interfaceAction
- Specified by:
getDisplayName
in interfaceModelObject
-
getUrlName
public String getUrlName()
- Specified by:
getUrlName
in interfaceAction
-
getArguments
@NonNull public Map<String,Object> getArguments()
Get the map of arguments used to instantiate theStep
, with aArgumentsAction.NotStoredReason
instead of the argument value supplied in the executed pipeline step if that value is filtered for size or security.- Returns:
- The arguments for the
Step
as withStepDescriptor.defineArguments(Step)
-
getArguments
@NonNull public static Map<String,Object> getArguments(@NonNull FlowNode n)
Get the map of arguments supplied to instantiate theStep
run in theFlowNode
given or empty if the arguments were not stored or the FlowNode was not a step.- Parameters:
n
- FlowNode to fetch Step arguments for (including placeholders for masked values).
-
getFilteredArguments
@NonNull public Map<String,Object> getFilteredArguments()
Get just the fully stored, non-null arguments This means the arguments with allArgumentsAction.NotStoredReason
or null values removed- Returns:
- Map of all completely stored arguments
-
getFilteredArguments
@NonNull public static Map<String,Object> getFilteredArguments(@NonNull FlowNode n)
Get just the fully stored, non-null arguments This means the arguments with allArgumentsAction.NotStoredReason
or null values removed- Parameters:
n
- FlowNode to get arguments for- Returns:
- Map of all completely stored arguments
-
getStepArgumentsAsString
@CheckForNull public static String getStepArgumentsAsString(@NonNull FlowNode n)
Return a tidy string description for the step arguments, or null if none is present or we can't make one SeeStepDescriptor.argumentsToString(Map)
for the rules
-
getArgumentsInternal
@NonNull protected abstract Map<String,Object> getArgumentsInternal()
Return a fast view of internal arguments, without creating immutable wrappers- Returns:
- Internal arguments
-
getArgumentValue
@CheckForNull public Object getArgumentValue(@NonNull String argumentName)
Get the value of a argument, or null if not present/not stored. UsegetArgumentValueOrReason(String)
if you want to return theArgumentsAction.NotStoredReason
rather than null.- Parameters:
argumentName
- Argument name of step to look up.- Returns:
- Argument value or null if not present/not stored.
-
getArgumentValueOrReason
@CheckForNull public Object getArgumentValueOrReason(@NonNull String argumentName)
Get the argument value or itsArgumentsAction.NotStoredReason
if it has been intentionally omitted.- Parameters:
argumentName
- Name of step argument to find value for- Returns:
- Argument value, null if nonexistent/null, or NotStoredReason if it existed by was masked out.
-
isUnmodifiedArguments
public boolean isUnmodifiedArguments()
Test ifStep
arguments are persisted in an unaltered form.- Returns:
- True if full arguments are retained, false if some have been removed for security, size, or other reasons.
-
getResolvedArguments
@NonNull public static Map<String,?> getResolvedArguments(@NonNull FlowNode n)
LikegetArguments(FlowNode)
but attempting to resolve actual classes. If you need to reconstruct actual classes of nested objects (for example to pass toPluginManager.whichPlugin(java.lang.Class)
), it is not trivial to get this information from the form in which they were supplied toDescribableModel.instantiate(java.util.Map<java.lang.String, ?>)
. For example, nested objects (where present and not aArgumentsAction.NotStoredReason
) might have been- an
UninstantiatedDescribable
, if given by a symbol - a
Map
, if given byDescribableModel.CLAZZ
- a
Describable
, if constructed directly (rare)
UninstantiatedDescribable
in all those cases. You could useUninstantiatedDescribable.getModel()
(where available) andDescribableModel.getType()
to access live classes. Where information is missing, this will just return the best it can. - an
-
-