Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-31842] Define status of a Controller #26

Merged
merged 1 commit into from
Jun 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ private synchronized int pid(FilePath ws) throws IOException, InterruptedExcepti
return null;
}

@Override public String getDiagnostics(FilePath workspace, Launcher launcher) throws IOException, InterruptedException {
return super.getDiagnostics(workspace, launcher) + " (pid: " + pid + ")";
}

private static final long serialVersionUID = 1L;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,13 @@ private static Launcher createLauncher(FilePath workspace) throws IOException, I
*/
public abstract void cleanup(FilePath workspace) throws IOException, InterruptedException;

/**
* Should be overridden to provide specific information about the status of an external process, for diagnostic purposes.
* @return {@link #toString} by default
*/
public String getDiagnostics(FilePath workspace, Launcher launcher) throws IOException, InterruptedException {
return toString();
}

private static final long serialVersionUID = 1L;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import hudson.Launcher;
import hudson.Util;
import hudson.model.TaskListener;
import hudson.remoting.Channel;
import hudson.remoting.RemoteOutputStream;
import hudson.remoting.VirtualChannel;
import hudson.slaves.WorkspaceList;
Expand Down Expand Up @@ -202,6 +203,19 @@ public FilePath getLogFile(FilePath workspace) throws IOException, InterruptedEx
return controlDir(workspace).child("jenkins-log.txt");
}

@Override public String getDiagnostics(FilePath workspace, Launcher launcher) throws IOException, InterruptedException {
FilePath cd = controlDir(workspace);
VirtualChannel channel = cd.getChannel();
String node = (channel instanceof Channel) ? ((Channel) channel).getName() : null;
String location = node != null ? cd.getRemote() + " on " + node : cd.getRemote();
Integer code = exitStatus(workspace, launcher);
if (code != null) {
return "completed process (code " + code + ") in " + location;
} else {
return "awaiting process completion in " + location;
}
}

private static final long serialVersionUID = 1L;
}

Expand Down