Class Common


  • public class Common
    extends Object
    Common utility functions.
    Author:
    Naresh Rayapati
    • Constructor Detail

      • Common

        public Common()
    • Method Detail

      • sanitizeURL

        public static String sanitizeURL​(String url)
        Attaches the "/" at end of given url.
        Parameters:
        url - url as a string.
        Returns:
        url which ends with "/"
      • log

        public static void log​(PrintStream logger,
                               Object message)
        Write a message to the given print stream.
        Parameters:
        logger - PrintStream
        message - to log.
      • getJobName

        public static String getJobName​(EnvVars envVars)
      • getBuildNumber

        public static String getBuildNumber​(PrintStream logger,
                                            EnvVars envVars)
        Returns build number from the given Environment Vars.
        Parameters:
        logger - PrintStream
        envVars - EnvVars
        Returns:
        build number of current job.
      • buildErrorResponse

        public static <T> ResponseData<T> buildErrorResponse​(Exception e)
        Builds error response from the given exception.
        Parameters:
        e - instance of Exception
        Returns:
        an instance of ResponseData
      • getRootCause

        public static Throwable getRootCause​(Throwable throwable)
        Returns actual Cause from the given exception.
        Returns:
        Throwable
      • prepareBuildUserName

        public static String prepareBuildUserName​(List<Cause> causes,
                                                  EnvVars envVars)
        Return the current build user.
        Parameters:
        causes - build causes.
        envVars - environment variables.
        Returns:
        user name.
      • prepareBuildCause

        public static String prepareBuildCause​(List<Cause> causes)
        Retrun the build cause.
        Returns:
        build cause.
      • prepareBuildUserId

        public static String prepareBuildUserId​(List<Cause> causes,
                                                EnvVars envVars)
        Return the current build user Id.
        Parameters:
        causes - build causes.
        envVars - environment variables.
        Returns:
        user name.
      • expandMacros

        public static Map expandMacros​(String tokens,
                                       Run<?,​?> run,
                                       FilePath ws,
                                       TaskListener listener)
        Expands given macro, see Token Marco plugin.