Class Utils


  • public class Utils
    extends Object
    Utility methods.
    Since:
    0.23
    Author:
    Bruno P. Kinoshita
    • Field Detail

      • LOGGER

        protected static final Logger LOGGER
    • Method Detail

      • getAllScriptlerScripts

        @Nonnull
        public static Set<org.jenkinsci.plugins.scriptler.config.Script> getAllScriptlerScripts()
        Returns all scriptler scripts available.
        Returns:
        all scriptler scripts available in Jenkins
      • isSelected

        public static boolean isSelected​(@Nullable
                                         Object obj)
        Checks whether a parameter value contains the :selected suffix, returning true if it does, false otherwise.
        Parameters:
        obj - parameter value
        Returns:
        true if the parameter name contains the :selected suffix false otherwise.
      • escapeSelected

        @Nonnull
        public static String escapeSelected​(@Nullable
                                            Object obj)
        Escapes the parameter value, removing the :selected suffix.
        Parameters:
        obj - parameter value
        Returns:
        escaped parameter value
      • isDisabled

        public static boolean isDisabled​(@Nullable
                                         Object obj)
        Checks whether a parameter value contains the :disabled suffix, returning true if it does, false otherwise.
        Parameters:
        obj - parameter value
        Returns:
        true if the parameter name contains the :disabled suffix false otherwise.
      • escapeDisabled

        @Nonnull
        public static String escapeDisabled​(@Nullable
                                            Object obj)
        Escapes the parameter value, removing the :disabled suffix.
        Parameters:
        obj - parameter value
        Returns:
        escaped parameter value
      • escapeSelectedAndDisabled

        @Nonnull
        public static String escapeSelectedAndDisabled​(@Nullable
                                                       Object obj)
        Escapes the parameter value, removing the :selected and :disabled suffixes.
        Parameters:
        obj - parameter value
        Returns:
        escaped parameter value
      • createRandomParameterName

        @Nonnull
        public static String createRandomParameterName​(@Nullable
                                                       String prefix,
                                                       @Nullable
                                                       String suffix)
        Creates a random parameter name.
        Parameters:
        prefix - parameter prefix
        suffix - parameter suffix
        Returns:
        random parameter name
      • getSystemEnv

        @Nonnull
        public static Map<String,​String> getSystemEnv()
        Helped method to return the system environment variables. The main advantage over calling the System.getenv method directly, is that we can mock this call (System is final).
        Returns:
        System environment variables as map
      • findProjectByParameterUUID

        @CheckForNull
        public static Project findProjectByParameterUUID​(@Nonnull
                                                         String parameterUUID)
        Find the current project give its parameter UUID.
        Parameters:
        parameterUUID - parameter UUID
        Returns:
        null if the current project cannot be found
        Since:
        1.3
      • getProjectParameterDefinitions

        @Nonnull
        public static List<ParameterDefinition> getProjectParameterDefinitions​(@Nonnull
                                                                               Project<?,​?> project)
        Get the parameter definitions for the given project.
        Parameters:
        project - the project for which the parameter definitions should be found
        Returns:
        parameter definitions or an empty list
        Since:
        1.3
      • getGlobalNodeProperties

        @Nonnull
        public static Map<String,​Object> getGlobalNodeProperties()
        Get a map with the global node properties.
        Returns:
        map with global node properties
        Since:
        1.6