public abstract class NodePoolJDKInstaller
extends hudson.tools.ToolInstaller
Generally, the `FilePath performInstallation(Node node, TaskListener tl, Connection connection)` method provides the installation implementation logic which leverages the connection to invoke required java installation commands on the remote NodePool slave instance.
Earlier implementations of derived classes include an Ubuntu OpenJDK installer and a more generic script installer which accepts an arbitrary script to run the installation (e.g. apt-get install openjdk-8-jre-headless -y).
Constructor and Description |
---|
NodePoolJDKInstaller() |
NodePoolJDKInstaller(String label)
Creates a new NodePool JDK installer.
|
Modifier and Type | Method and Description |
---|---|
protected int |
executeCommand(hudson.model.TaskListener log,
hudson.Launcher launcher,
String... commands)
A simple wrapper method for launching a set of commands.
|
protected int |
executeCommand(hudson.model.TaskListener log,
hudson.Launcher launcher,
String workingDir,
String... commands)
A simple wrapper method for launching a set of commands.
|
protected void |
fine(hudson.model.TaskListener listener,
String msg)
Logs the specified message as Level.FINE to both the logger and the task listener.
|
String |
getInstallWorkingDir()
Returns the installation working directory for the installer (typically: /tmp).
|
abstract String |
getJavaHome()
Returns the Java home folder associated with this installation (value set by the implementation class).
|
protected static String |
getTimestamp()
Returns the formatted current time stamp.
|
protected void |
info(hudson.model.TaskListener listener,
String msg)
Logs the specified message as Level.FINE to both the logger and the task listener.
|
boolean |
isJavaInstalled(hudson.Launcher launcher,
hudson.model.TaskListener tl)
Routine to run a remote command to determine if java is installed (e.g.
|
protected void |
log(Level lvl,
hudson.model.TaskListener listener,
String msg)
Logs the specified message to both the logger and the task listener.
|
abstract hudson.FilePath |
performInstallation(hudson.model.Node node,
hudson.model.TaskListener tl,
com.trilead.ssh2.Connection connection)
Ensure that the configured tool is really installed.
|
hudson.FilePath |
performInstallation(hudson.tools.ToolInstallation tool,
hudson.model.Node node,
hudson.model.TaskListener tl)
Ensure that the configured tool is really installed.
|
void |
setInstallWorkingDir(String installWorkingDir)
Sets the installation working directory for the installer.
|
protected void |
warn(hudson.model.TaskListener listener,
String msg)
Logs the specified message as Level.FINE to both the logger and the task listener.
|
public NodePoolJDKInstaller()
public NodePoolJDKInstaller(String label)
label
- the label associated with this installerpublic String getInstallWorkingDir()
public void setInstallWorkingDir(String installWorkingDir) throws IllegalArgumentException
installWorkingDir
- the installation working directory.IllegalArgumentException
- if installWorkingDir is null or emptypublic abstract String getJavaHome()
public hudson.FilePath performInstallation(hudson.tools.ToolInstallation tool, hudson.model.Node node, hudson.model.TaskListener tl) throws IOException, InterruptedException
performInstallation
in class hudson.tools.ToolInstaller
tool
- the tool being installednode
- the computer on which to install the tooltl
- any status messages produced by the installation go hereIOException
- if the installation failsInterruptedException
- if communication with a agent is interruptedpublic abstract hudson.FilePath performInstallation(hudson.model.Node node, hudson.model.TaskListener tl, com.trilead.ssh2.Connection connection) throws IOException, InterruptedException
node
- the computer on which to install the tooltl
- any status messages produced by the installation go hereconnection
- the connection objectIOException
- if the installation failsInterruptedException
- if communication with a agent is interruptedpublic boolean isJavaInstalled(hudson.Launcher launcher, hudson.model.TaskListener tl) throws IOException, InterruptedException
launcher
- the launchertl
- the task listenerIOException
- if an error occurs while launching and running the java version commandInterruptedException
- if communication with a agent is interruptedprotected static String getTimestamp()
protected void log(Level lvl, hudson.model.TaskListener listener, String msg)
lvl
- the log levellistener
- the task listenermsg
- the message to logprotected void fine(hudson.model.TaskListener listener, String msg)
listener
- the task listenermsg
- the message to logprotected void info(hudson.model.TaskListener listener, String msg)
listener
- the task listenermsg
- the message to logprotected void warn(hudson.model.TaskListener listener, String msg)
listener
- the task listenermsg
- the message to logprotected int executeCommand(hudson.model.TaskListener log, hudson.Launcher launcher, String... commands) throws IOException, InterruptedException
log
- the task listenerlauncher
- the launchercommands
- one or more commands (as a vararg)IOException
- if an error occurs while launching and running the commandInterruptedException
- if an error occurs while launching and running the commandprotected int executeCommand(hudson.model.TaskListener log, hudson.Launcher launcher, String workingDir, String... commands) throws IOException, InterruptedException
log
- the task listenerlauncher
- the launcherworkingDir
- the working directory when running the commandcommands
- one or more commands (as a vararg)IOException
- if an error occurs while launching and running the commandInterruptedException
- if an error occurs while launching and running the commandCopyright © 2016–2018. All rights reserved.