Class StorageUtil
java.lang.Object
com.google.jenkins.plugins.storage.util.StorageUtil
A class to contain common utility operations
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetRelative(FilePath include, FilePath workspace) Compute the relative path of the given file inclusion, relative to the given workspace.static StringgetStrippedFilename(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.static com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentialslookupCredentials(String credentials) Look up credentials by name.static StringreplaceMacro(String name, Run<?, ?> run, TaskListener listener) Perform variable expansion for non-pipeline steps.
-
Constructor Details
-
StorageUtil
public StorageUtil()
-
-
Method Details
-
getRelative
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
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, IOExceptionPerform variable expansion for non-pipeline steps.- Parameters:
name- The name, potentially including with variablesrun- 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.
-