@RequestMapping(value = "/scan", method = RequestMethod.POST) public void fire(@RequestBody RequestMessage requestMessage) throws IOException, InterruptedException, URISyntaxException { try { String s = null; System.out.println(requestMessage); JenkinsServer jenkins = new JenkinsServer(new URI(url), user, pass); Map<String, Job> jobs = jenkins.getJobs(); JobWithDetails job = jobs.get(requestMessage.getJobName().toLowerCase()).details(); BuildWithDetails buildWithDetails = job.getLastBuild().details(); String result = buildWithDetails.getResult().toString(); System.out.println("LAST JOB: " + result + " - RESULT"); if ("FAILURE".equals(result) && !fired) { System.out.println("Failure - DISPARANDO"); fired = true; Process p = Runtime.getRuntime().exec(command); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); // read the output from the command System.out.println("Here is the standard output of the command:\n"); while ((s = stdInput.readLine()) != null) { System.out.println(s); } // read any errors from the attempted command System.out.println("Here is the standard error of the command (if any):\n"); while ((s = stdError.readLine()) != null) { System.out.println(s); } } if ("SUCCED".equals(result)) { fired = false; } // System.exit(0); } catch (IOException e) { System.out.println("exception happened - here's what I know: "); e.printStackTrace(); // System.exit(-1); } }