Hi,

I want Jenkins to get a threaddump of all forked JVMs automatically in case
of a build timeout (using env entry set by build timeout plugin). If I have
the Job on master, the groovy system script below can find the forked
processes without any problem:

import hudson.*;
import hudson.util.*;
import hudson.model.*;
import hudson.util.ProcessTree.OSProcess;

EnvVars variables = build.getEnvironment();

//if ( variables.get("TIMEOUT_HAPPENED") != null ) {
if (true) {
  Map<String,String> expectedEnvironmentVariables = new
HashMap<String,String>();
  String buildId = variables.get("BUILD_ID");
  if ( buildId != null ) {
    expectedEnvironmentVariables.put("BUILD_ID",buildId);
  }
  String jenkinsServerCookie = variables.get("JENKINS_SERVER_COOKIE");
  if ( jenkinsServerCookie != null ) {

expectedEnvironmentVariables.put("JENKINS_SERVER_COOKIE",jenkinsServerCookie);
  }
  println "Expected env vars " + expectedEnvironmentVariables;
  ProcessTree tree = ProcessTree.get();
  Iterator<OSProcess> processIterator = tree.iterator();
  while( processIterator.hasNext() ) {
    OSProcess currentProcess = processIterator.next();
    if ( currentProcess.hasMatchingEnvVars(expectedEnvironmentVariables) ) {
     println "" + currentProcess.getPid() + " " +
currentProcess.getArguments();
    }
  }
}

However if the job runs on a slave, of course the groovy snippet on main
does not find anything. Is there a way to run a groovy system script on the
slave? How can I the required classes there (processtree and so on)?

I guess the processtreekiller runs somehow anyway on the slaves. I could
use some similar approach. Could you give me an advice?

Thanks and regards,

Gábor Lipták

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to