Class StorageUtil


  • public class StorageUtil
    extends Object
    A class to contain common utility operations
    • Constructor Detail

      • StorageUtil

        public StorageUtil()
    • Method Detail

      • getRelative

        public static String getRelative​(FilePath include,
                                         FilePath workspace)
                                  throws UploadException
        Compute the relative path of the given file inclusion, relative to the given workspace. If the path is absolute, it returns the root-relative path instead.
        Parameters:
        include - The file whose relative path we are computing.
        workspace - The workspace containing the included file.
        Returns:
        The unix-style relative path of file.
        Throws:
        UploadException - when the input is malformed
      • getStrippedFilename

        public static String getStrippedFilename​(String filename,
                                                 String pathPrefix)
        If a path prefix to strip has been specified, and the input string starts with that prefix, returns the portion of the input after that prefix. Otherwise, returns the unmodified input.
        Parameters:
        filename - Input string to strip.
        pathPrefix - Name of the path prefix to strip on.
        Returns:
        Remaining portion of the input after prefix is stripped.
      • replaceMacro

        public static String replaceMacro​(String name,
                                          Run<?,​?> run,
                                          TaskListener listener)
                                   throws InterruptedException,
                                          IOException
        Perform variable expansion for non-pipeline steps.
        Parameters:
        name - The name, potentially including with variables
        run - The current run, used to determine pipeline status and to get environment.
        listener - Task listener, used to get environment
        Returns:
        The updated name, with variables resolved
        Throws:
        InterruptedException - If getting the environment of the run throws an InterruptedException.
        IOException - If getting the environment of the run throws an IOException.
      • lookupCredentials

        public static com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials lookupCredentials​(String credentials)
                                                                                                     throws AbortException
        Look up credentials by name.
        Parameters:
        credentials - The name of the credentials to look up.
        Returns:
        The corresponding GoogleRobotCredentials.
        Throws:
        AbortException - If credentials not found.