Class ArgumentsAction
java.lang.Object
org.jenkinsci.plugins.workflow.actions.ArgumentsAction
- All Implemented Interfaces:
Action
,ModelObject
,PersistentAction
Stores some or all of the arguments used to create and configure the
Step
executed by a FlowNode
.
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 a ArgumentsAction.NotStoredReason
for security or performance.
Important note: these APIs do not provide recursive guarantees that returned datastructures are immutable.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Used as a placeholder marker forStep
arguments not stored for various reasons. -
Field Summary
Modifier and TypeFieldDescriptionprotected static final int
Largest String, Collection, or array size we'll retain -- provides a rough size limit on any single field. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet 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.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.Return a fast view of internal arguments, without creating immutable wrappersgetArgumentValue
(String argumentName) Get the value of a argument, or null if not present/not stored.getArgumentValueOrReason
(String argumentName) Get the argument value or itsArgumentsAction.NotStoredReason
if it has been intentionally omitted.Get just the fully stored, non-null arguments This means the arguments with allArgumentsAction.NotStoredReason
or null values removedGet just the fully stored, non-null arguments This means the arguments with allArgumentsAction.NotStoredReason
or null values removedLikegetArguments(FlowNode)
but attempting to resolve actual classes.static String
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 rulesprotected static boolean
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
Test ifStep
arguments are persisted in an unaltered form.
-
Field Details
-
MAX_RETAINED_LENGTH
protected static final int MAX_RETAINED_LENGTHLargest String, Collection, or array size we'll retain -- provides a rough size limit on any single field. Set to 0 or -1 to remove length limits.
-
-
Constructor Details
-
ArgumentsAction
public ArgumentsAction()
-
-
Method Details
-
isOversized
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
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
- Specified by:
getIconFileName
in interfaceAction
-
getDisplayName
- Specified by:
getDisplayName
in interfaceAction
- Specified by:
getDisplayName
in interfaceModelObject
-
getUrlName
- Specified by:
getUrlName
in interfaceAction
-
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
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
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
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
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
Return a fast view of internal arguments, without creating immutable wrappers- Returns:
- Internal arguments
-
getArgumentValue
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
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
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
-