Class FileMonitoringTask
- java.lang.Object
-
- hudson.model.AbstractDescribableImpl<DurableTask>
-
- org.jenkinsci.plugins.durabletask.DurableTask
-
- org.jenkinsci.plugins.durabletask.FileMonitoringTask
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<DurableTask>
- Direct Known Subclasses:
BourneShellScript
,PowershellScript
,WindowsBatchScript
public abstract class FileMonitoringTask extends DurableTask
A task which forks some external command and then waits for log and status files to be updated/created.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
FileMonitoringTask.FileMonitoringController
Tails a log file and watches for an exit status file.-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
BINARY_RESOURCE_PREFIX
protected static String
COOKIE
-
Constructor Summary
Constructors Constructor Description FileMonitoringTask()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
charset(Charset cs)
Requests that a specified charset be used to transcode process output.void
defaultCharset()
Requests that the node’s system charset be used to transcode process output.protected FileMonitoringTask.FileMonitoringController
doLaunch(FilePath workspace, Launcher launcher, TaskListener listener, EnvVars envVars)
Should start a process which sends output to log file in the workspace and finally writes its exit code to result file.protected static Map<String,String>
escape(EnvVars envVars)
JENKINS-40734: blocks the substitutions ofEnvVars.overrideExpandingAll(java.util.Map<java.lang.String, java.lang.String>)
done byLauncher
.protected static AgentInfo
getAgentInfo(FilePath nodeRoot)
protected static FilePath
getNodeRoot(FilePath workspace)
Controller
launch(EnvVars env, FilePath workspace, Launcher launcher, TaskListener listener)
Launches a durable task.protected FileMonitoringTask.FileMonitoringController
launchWithCookie(FilePath workspace, Launcher launcher, TaskListener listener, EnvVars envVars, String cookieVariable, String cookieValue)
protected static FilePath
requestBinary(FilePath nodeRoot, AgentInfo agentInfo, FilePath ws, FileMonitoringTask.FileMonitoringController c)
Returns path of binary on agent.protected static FilePath
requestBinary(FilePath ws, FileMonitoringTask.FileMonitoringController c)
Returns path of binary on agent.-
Methods inherited from class org.jenkinsci.plugins.durabletask.DurableTask
captureOutput, getDescriptor
-
-
-
-
Field Detail
-
COOKIE
protected static final String COOKIE
- See Also:
- Constant Field Values
-
BINARY_RESOURCE_PREFIX
protected static final String BINARY_RESOURCE_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
launch
public final Controller launch(EnvVars env, FilePath workspace, Launcher launcher, TaskListener listener) throws IOException, InterruptedException
Description copied from class:DurableTask
Launches a durable task.- Specified by:
launch
in classDurableTask
- Parameters:
env
- basic environment variables to use during launchworkspace
- the workspace to uselauncher
- a way to start processeslistener
- log output for the build- Returns:
- a way to check up on the task’s subsequent status
- Throws:
IOException
InterruptedException
-
launchWithCookie
protected FileMonitoringTask.FileMonitoringController launchWithCookie(FilePath workspace, Launcher launcher, TaskListener listener, EnvVars envVars, String cookieVariable, String cookieValue) throws IOException, InterruptedException
- Throws:
IOException
InterruptedException
-
charset
public final void charset(Charset cs)
Description copied from class:DurableTask
Requests that a specified charset be used to transcode process output. The encoding ofController.writeLog(hudson.FilePath, java.io.OutputStream)
andController.getOutput(hudson.FilePath, hudson.Launcher)
is then presumed to be UTF-8. If not called, no translation is performed.- Overrides:
charset
in classDurableTask
- Parameters:
cs
- the character set in which process output is expected to be
-
defaultCharset
public final void defaultCharset()
Description copied from class:DurableTask
Requests that the node’s system charset be used to transcode process output. The encoding ofController.writeLog(hudson.FilePath, java.io.OutputStream)
andController.getOutput(hudson.FilePath, hudson.Launcher)
is then presumed to be UTF-8. If not called, no translation is performed.- Overrides:
defaultCharset
in classDurableTask
-
doLaunch
protected FileMonitoringTask.FileMonitoringController doLaunch(FilePath workspace, Launcher launcher, TaskListener listener, EnvVars envVars) throws IOException, InterruptedException
Should start a process which sends output to log file in the workspace and finally writes its exit code to result file.- Parameters:
workspace
- the workspace to uselauncher
- a way to launch processeslistener
- build console logenvVars
- recommended environment for the subprocess- Returns:
- a specialized controller
- Throws:
IOException
InterruptedException
-
escape
protected static Map<String,String> escape(EnvVars envVars)
JENKINS-40734: blocks the substitutions ofEnvVars.overrideExpandingAll(java.util.Map<java.lang.String, java.lang.String>)
done byLauncher
.
-
getNodeRoot
protected static FilePath getNodeRoot(FilePath workspace) throws IOException
- Throws:
IOException
-
getAgentInfo
protected static AgentInfo getAgentInfo(FilePath nodeRoot) throws IOException, InterruptedException
- Throws:
IOException
InterruptedException
-
requestBinary
@CheckForNull protected static FilePath requestBinary(FilePath ws, FileMonitoringTask.FileMonitoringController c) throws IOException, InterruptedException
Returns path of binary on agent. Copies binary to agent if it does not exist- Throws:
IOException
InterruptedException
-
requestBinary
@CheckForNull protected static FilePath requestBinary(FilePath nodeRoot, AgentInfo agentInfo, FilePath ws, FileMonitoringTask.FileMonitoringController c) throws IOException, InterruptedException
Returns path of binary on agent. Copies binary to agent if it does not exist- Throws:
IOException
InterruptedException
-
-