Class 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 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.
    • Field Detail

      • MAX_RETAINED_LENGTH

        protected static final int MAX_RETAINED_LENGTH
        Largest 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 Detail

      • ArgumentsAction

        public ArgumentsAction()
    • 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 inputs
        maxElements - 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 like isOversized(Object, int) but using MAX_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.
      • getArguments

        @NonNull
        public Map<String,​Object> getArguments()
        Get the map of arguments used to instantiate the Step, with a ArgumentsAction.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 with StepDescriptor.defineArguments(Step)
      • getArguments

        @NonNull
        public static Map<String,​Object> getArguments​(@NonNull
                                                            FlowNode n)
        Get the map of arguments supplied to instantiate the Step run in the FlowNode 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 all ArgumentsAction.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 all ArgumentsAction.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 See StepDescriptor.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. Use getArgumentValueOrReason(String) if you want to return the ArgumentsAction.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 its ArgumentsAction.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 if Step 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)
        Like getArguments(FlowNode) but attempting to resolve actual classes. If you need to reconstruct actual classes of nested objects (for example to pass to PluginManager.whichPlugin(java.lang.Class)), it is not trivial to get this information from the form in which they were supplied to DescribableModel.instantiate(java.util.Map<java.lang.String, ?>). For example, nested objects (where present and not a ArgumentsAction.NotStoredReason) might have been
        • an UninstantiatedDescribable, if given by a symbol
        • a Map, if given by DescribableModel.CLAZZ
        • a Describable, if constructed directly (rare)
        This method will instead attempt to return a normalized tree using UninstantiatedDescribable in all those cases. You could use UninstantiatedDescribable.getModel() (where available) and DescribableModel.getType() to access live classes. Where information is missing, this will just return the best it can.