Skip to content
Permalink
Browse files

[JENKINS-39150] report remoting diagnostics when it's available

Since this plugin cannot assume the version of core, access the method
in question via reflection (and also report the failure to find that
method, so that we have evidence either way.)
  • Loading branch information
kohsuke committed Oct 21, 2016
1 parent b7e93c4 commit d5b009c20f80839b49641d0419f6475e1cce513f
Showing with 57 additions and 0 deletions.
  1. +6 −0 pom.xml
  2. +51 −0 src/main/java/com/cloudbees/jenkins/support/impl/RemotingDiagnostics.java
@@ -104,6 +104,12 @@
<version>1.7.8</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>remoting</artifactId>
<version>2.62.3-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
@@ -0,0 +1,51 @@
package com.cloudbees.jenkins.support.impl;

import com.cloudbees.jenkins.support.api.Component;
import com.cloudbees.jenkins.support.api.Container;
import com.cloudbees.jenkins.support.api.PrintedContent;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.remoting.Channel;
import hudson.security.Permission;
import jenkins.model.Jenkins;

import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Set;

/**
* Captures diagnostics information from remoting channels.
*
* @author Kohsuke Kawaguchi
*/
public class RemotingDiagnostics extends Component {

@NonNull
@Override
public Set<Permission> getRequiredPermissions() {
return Collections.singleton(Jenkins.ADMINISTER);
}

@NonNull
@Override
public String getDisplayName() {
return "Remoting Channel Diagnostics";
}

@Override
public void addContents(@NonNull Container container) {
container.add(new PrintedContent("channel-diagnostics.md") {
@Override
protected void printTo(PrintWriter out) throws IOException {
// this method is new in remoting. see JENKINS-39150 change in remoting
try {
Method m = Channel.class.getMethod("dumpDiagnosticsForAll", PrintWriter.class);
m.invoke(null,out);
} catch (Exception e) {
e.printStackTrace(out);
}
}
});
}
}

0 comments on commit d5b009c

Please sign in to comment.
You can’t perform that action at this time.