Class FileUtil
- java.lang.Object
-
- com.veracode.jenkins.plugin.utils.FileUtil
-
public final class FileUtil extends Object
The FileUtil is a utility class for working with files and directories.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FileUtil.FileCallableImpl
ImplementsFileCallable
'sinvoke
method, which is executed on the machine containing the file whose file path is represented by theFilePath
object on which theact
method is called.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
cleanUpBuildProperties(Run<?,?> run, TaskListener listener)
Deletes the properties file of the specified build.static boolean
copyJarFiles(AbstractBuild<?,?> build, FilePath local, FilePath remote, PrintStream ps)
Copies the Veracode API Wrapper to the remote location.static boolean
createBuildPropertiesFile(Run<?,?> run, Properties properties, TaskListener listener)
Creates a properties file for the specified build with the given properties.static boolean
deleteDirectory(File file)
Deletes the file represented by the specifiedFile
object.static FilePath
getLocalWorkspaceFilepath()
Returns the Veracode API Wrapper location situated in master.static String
getStringFilePath(FilePath filePath)
Returns a String that corresponds to the textual representation of the file path of the file represented by the specifiedFilePath
object.static String[]
getStringFilePaths(FilePath[] filePaths)
Returns a String array whose elements correspond to the textual representation of the file paths of the files represented by the elements of the specifiedFilePath
array.static Properties
readBuildPropertiesFile(Run<?,?> run, TaskListener listener)
Returns the properties of the specified build.
-
-
-
Method Detail
-
deleteDirectory
public static boolean deleteDirectory(File file)
Deletes the file represented by the specifiedFile
object. Iffile
represents a directory it also recursively deletes its contents.- Parameters:
file
- aFile
object.- Returns:
- a boolean.
-
getStringFilePaths
public static String[] getStringFilePaths(FilePath[] filePaths) throws IOException, InterruptedException
Returns a String array whose elements correspond to the textual representation of the file paths of the files represented by the elements of the specifiedFilePath
array.- Parameters:
filePaths
- an array ofFilePath
objects.- Returns:
- an array of
String
objects. - Throws:
IOException
- if any.InterruptedException
- if any.
-
getStringFilePath
public static String getStringFilePath(FilePath filePath) throws IOException, InterruptedException
Returns a String that corresponds to the textual representation of the file path of the file represented by the specifiedFilePath
object.- Parameters:
filePath
- aFilePath
object.- Returns:
- a
String
object. - Throws:
IOException
- if any.InterruptedException
- if any.
-
copyJarFiles
public static boolean copyJarFiles(AbstractBuild<?,?> build, FilePath local, FilePath remote, PrintStream ps) throws Exception
Copies the Veracode API Wrapper to the remote location.- Parameters:
build
- aAbstractBuild
object.local
- aFilePath
object.remote
- aFilePath
object.ps
- aPrintStream
object.- Returns:
- a boolean.
- Throws:
Exception
- if any.
-
getLocalWorkspaceFilepath
public static FilePath getLocalWorkspaceFilepath() throws URISyntaxException
Returns the Veracode API Wrapper location situated in master.- Returns:
- a
FilePath
object. - Throws:
URISyntaxException
- if any.
-
cleanUpBuildProperties
public static boolean cleanUpBuildProperties(Run<?,?> run, TaskListener listener)
Deletes the properties file of the specified build.- Parameters:
run
- aRun
object.listener
- aTaskListener
object.- Returns:
- a boolean.
-
createBuildPropertiesFile
public static boolean createBuildPropertiesFile(Run<?,?> run, Properties properties, TaskListener listener) throws IOException
Creates a properties file for the specified build with the given properties.- Parameters:
run
- aRun
object.properties
- aProperties
object.listener
- aTaskListener
object.- Returns:
- a boolean.
- Throws:
IOException
- if any.
-
readBuildPropertiesFile
public static Properties readBuildPropertiesFile(Run<?,?> run, TaskListener listener) throws IOException
Returns the properties of the specified build.- Parameters:
run
- aRun
object.listener
- aTaskListener
object.- Returns:
- a
Properties
object. - Throws:
IOException
- if any.
-
-