public static void main(String[] args) {
    JenkinsServer jenkins = null;
    try {
      jenkins = new JenkinsServer(new URI("http://130.211.189.253"), "", "");
      jenkins.createJob(
          "ProgramaticJob", inputStream2String(new FileInputStream(new File("config.xml"))));
    } catch (URISyntaxException | IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    //
    //        try {
    //
    //            // jenkins.createJob(jobName, jobXml);
    //            Map<String, Job> jobs = jenkins.getJobs();
    //            for (String s : jobs.keySet()) {
    //                // System.out.println(s);
    //                System.out.println(jobs.get(s).details().details());
    //            }
    //        } catch (IOException e) {
    //            // TODO Auto-generated catch block
    //            e.printStackTrace();
    //        }

  }
  @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);
    }
  }