Package org.jenkinsci.plugins.workflow
Class FilePathUtils
- java.lang.Object
-
- org.jenkinsci.plugins.workflow.FilePathUtils
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FilePathUtils.Listener
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FilePath
find(String node, String path)
Attempts to create a live file handle based on persistable data.static String
getNodeName(FilePath f)
Same asgetNodeNameOrNull(hudson.FilePath)
but throws a diagnostic exception in case of failure.static String
getNodeNameOrNull(FilePath f)
Looks up theNode.getNodeName()
corresponding to a given file.
-
-
-
Method Detail
-
getNodeNameOrNull
@CheckForNull public static String getNodeNameOrNull(@NonNull FilePath f)
Looks up theNode.getNodeName()
corresponding to a given file. Compared toFilePath.toComputer()
this has two advantages:- it will still report a configured agent name even if the agent was subsequently disconnected (i.e., the
FilePath
is invalid) - it will still report a node name even if the agent is connected but currently has no executors
- Parameters:
f
- a file, possibly remote- Returns:
- a node name (
""
for the controller), if known, else null
- it will still report a configured agent name even if the agent was subsequently disconnected (i.e., the
-
getNodeName
@NonNull public static String getNodeName(@NonNull FilePath f) throws IllegalStateException
Same asgetNodeNameOrNull(hudson.FilePath)
but throws a diagnostic exception in case of failure.- Parameters:
f
- a file, possible remote- Returns:
- a node name (
""
for the controller), if known - Throws:
IllegalStateException
- if the association to a node is unknown
-
find
@CheckForNull public static FilePath find(@NonNull String node, @NonNull String path)
Attempts to create a live file handle based on persistable data.- Parameters:
node
- a name as returned bygetNodeName(hudson.FilePath)
path
- a path as returned byFilePath.getRemote()
- Returns:
- a corresponding file handle, if a node with that name is online, else null
-
-