public final class UtilitiesFile extends Object
Modifier and Type | Field and Description |
---|---|
static Pattern |
ALL_FILES_PATTERN
Pattern used to get all files from directory or directory structure .* stands for anything but
newlines.
|
static String |
ALL_FILES_REGEX_STRING
String used as regexp to get all files from directory or directory structure .* stands for
anything but newlines.
|
static String |
ZIP_FILE_PREFIX
Used in the zip file name as the identifier for the zip file to be made.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
createRemoteDirectory(String name,
hudson.FilePath workspace,
hudson.model.TaskListener listener)
Creates a directory in the specified workspace.
|
static List<hudson.FilePath> |
getArtifacts(hudson.model.Run<?,?> run,
Pattern pattern,
hudson.FilePath directoryToScan)
Returns any produced artifacts for the build.
|
static List<hudson.FilePath> |
getFiles(hudson.FilePath fileDirectory,
boolean includeSubdirectories,
Pattern pattern,
hudson.model.Run<?,?> run,
hudson.model.TaskListener listener)
Returns files in a directory
|
static hudson.FilePath |
packageFiles(hudson.FilePath workspace,
List<hudson.FilePath> files,
String zipFileName)
Method zips files at the location of the first file.
|
static Pattern |
patternOrAll(String pattern)
A convenience method which either returns a pattern which includes all files or a pattern for
the given string.
|
static boolean |
removeFilePackage(hudson.FilePath zipFile) |
static hudson.FilePath |
reportsDirectory(hudson.model.Run<?,?> run)
Convenience method for reports directory.
|
public static final String ALL_FILES_REGEX_STRING
public static final Pattern ALL_FILES_PATTERN
public static final String ZIP_FILE_PREFIX
public static List<hudson.FilePath> getArtifacts(hudson.model.Run<?,?> run, Pattern pattern, hudson.FilePath directoryToScan)
run
- Instance of the buildpattern
- Regexp pattern used for including only certain artifactsdirectoryToScan
- the relative path in workspace to scanpublic static List<hudson.FilePath> getFiles(hudson.FilePath fileDirectory, boolean includeSubdirectories, Pattern pattern, hudson.model.Run<?,?> run, hudson.model.TaskListener listener)
fileDirectory
- Name of the directory to parse through for filesincludeSubdirectories
- If true the method returns all files from the directory structure.pattern
- Regex to include only certain files. If all is required use
UtilitiesFile.ALL_FILES_PATTERNrun
- Jenkins build run instancelistener
- Jenkins consolepublic static hudson.FilePath packageFiles(hudson.FilePath workspace, List<hudson.FilePath> files, String zipFileName) throws Exception
workspace
- the directory to make the zip file and the base for all listed files.files
- List of file pathszipFileName
- Name for the zip fileIOException
- thrown when adding files to zip failsException
public static boolean removeFilePackage(hudson.FilePath zipFile) throws Exception
Exception
public static boolean createRemoteDirectory(String name, hudson.FilePath workspace, hudson.model.TaskListener listener) throws InterruptedException, IOException
name
- The name of the directory to createworkspace
- The workspace in which to create the directorylistener
- The build listener for logging information and possible errors to build
console.IOException
- thrown when cannot read location/create zip into itInterruptedException
- on interrupt (perhaps build cancellation etc)public static hudson.FilePath reportsDirectory(hudson.model.Run<?,?> run) throws IOException, InterruptedException
run
- The run instance of the buildIOException
- Failure to read/create directoryInterruptedException
- Failure to read/create directorypublic static Pattern patternOrAll(String pattern)
pattern
- The string representation of the pattern.Copyright © 2016–2023. All rights reserved.