Ejemplo n.º 1
0
 public void updateJob(ApplicationInfo appInfo, CIJob job) throws PhrescoException {
   if (debugEnabled) {
     S_LOGGER.debug(
         "Entering Method ProjectAdministratorImpl.updateJob(Project project, CIJob job)");
   }
   FileWriter writer = null;
   try {
     CIJobStatus jobStatus = configureJob(job, FrameworkConstants.CI_UPDATE_JOB_COMMAND);
     if (jobStatus.getCode() == -1) {
       throw new PhrescoException(jobStatus.getMessage());
     }
     if (debugEnabled) {
       S_LOGGER.debug("getCustomModules() ProjectInfo = " + appInfo);
     }
     updateJsonJob(appInfo, job);
   } catch (ClientHandlerException ex) {
     if (debugEnabled) {
       S_LOGGER.error(ex.getLocalizedMessage());
     }
     throw new PhrescoException(ex);
   } finally {
     if (writer != null) {
       try {
         writer.close();
       } catch (IOException e) {
         if (debugEnabled) {
           S_LOGGER.error(e.getLocalizedMessage());
         }
       }
     }
   }
 }
Ejemplo n.º 2
0
Archivo: CI.java Proyecto: ab-k/phresco
  public String build() {
    S_LOGGER.debug("Entering Method  CI.build()");
    try {
      ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
      Project project = administrator.getProject(projectCode);
      String[] selectedJobs = getHttpRequest().getParameterValues(REQ_SELECTED_JOBS_LIST);

      CIJobStatus ciJobStatus = administrator.buildJobs(project, Arrays.asList(selectedJobs));
      if (ciJobStatus.getCode() == JOB_STATUS_NOTOK) {
        S_LOGGER.debug("Jenkins build job status code " + ciJobStatus.getCode());
        addActionError(getText(ciJobStatus.getMessage()));
      } else {
        S_LOGGER.debug("Jenkins build job status code " + ciJobStatus.getCode());
        addActionMessage(getText(ciJobStatus.getMessage()));
      }
      getHttpRequest().setAttribute(REQ_SELECTED_MENU, APPLICATIONS);
      getHttpRequest().setAttribute(CI_BUILD_TRIGGERED_FROM_UI, TRUE);
    } catch (Exception e) {
      getHttpRequest().setAttribute(CI_BUILD_TRIGGERED_FROM_UI, FALSE);
      S_LOGGER.error(
          "Entered into catch block of CI.build()" + FrameworkUtil.getStackTraceAsString(e));
      addActionMessage(getText(CI_BUILD_FAILED, e.getLocalizedMessage()));
    }
    return ci();
  }
Ejemplo n.º 3
0
Archivo: CI.java Proyecto: ab-k/phresco
  public String deleteCIBuild() {
    S_LOGGER.debug("Entering Method  CI.deleteCIBuild()");
    String[] selectedBuilds = getHttpRequest().getParameterValues(REQ_SELECTED_BUILDS_LIST);
    S_LOGGER.debug("selectedBuilds " + selectedBuilds.toString());
    // job name and builds
    Map<String, List<String>> buildsTobeDeleted = new HashMap<String, List<String>>();
    for (String build : selectedBuilds) {
      S_LOGGER.debug("Build" + build);
      String[] split = build.split(",");
      S_LOGGER.debug("split " + split[0]);
      List<String> buildNumbers = new ArrayList<String>();
      if (buildsTobeDeleted.containsKey(split[0])) {
        List<String> listBuildNos = buildsTobeDeleted.get(split[0]);
        listBuildNos.add(split[1]);
        buildsTobeDeleted.put(split[0], listBuildNos);
      } else {
        buildNumbers.add(split[1]);
        buildsTobeDeleted.put(split[0], buildNumbers);
      }
    }

    Iterator iterator = buildsTobeDeleted.keySet().iterator();
    while (iterator.hasNext()) {
      String jobName = iterator.next().toString();
      List<String> versions = buildsTobeDeleted.get(jobName);
      S_LOGGER.debug("jobName " + jobName + " builds " + versions);
    }
    try {
      ProjectAdministrator administrator = getProjectAdministrator();
      Project project = administrator.getProject(projectCode);
      CIJobStatus ciJobStatus = administrator.deleteCIBuild(project, buildsTobeDeleted);
      if (ciJobStatus.getCode() == JOB_STATUS_NOTOK) {
        S_LOGGER.debug("Jenkins delete build status code " + ciJobStatus.getCode());
        addActionError(getText(ciJobStatus.getMessage()));
      } else {
        S_LOGGER.debug("Jenkins delete build status code " + ciJobStatus.getCode());
        addActionMessage(getText(ciJobStatus.getMessage()));
      }
      getHttpRequest().setAttribute("project", project);
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into catch block of CI.deleteCIBuild()"
              + FrameworkUtil.getStackTraceAsString(e));
      new LogErrorReport(e, "Build delete");
    }
    getHttpRequest().setAttribute(REQ_SELECTED_MENU, APPLICATIONS);
    return ci();
  }
Ejemplo n.º 4
0
Archivo: CI.java Proyecto: ab-k/phresco
 public String deleteCIJob() {
   S_LOGGER.debug("Entering Method  CI.deleteCIJob()");
   String[] selectedJobs = getHttpRequest().getParameterValues(REQ_SELECTED_JOBS_LIST);
   S_LOGGER.debug("delete selectedJobs " + selectedJobs);
   try {
     ProjectAdministrator administrator = getProjectAdministrator();
     Project project = administrator.getProject(projectCode);
     CIJobStatus ciJobStatus = administrator.deleteCIJobs(project, Arrays.asList(selectedJobs));
     if (ciJobStatus.getCode() == JOB_STATUS_NOTOK) {
       S_LOGGER.debug("Jenkins delete job status code " + ciJobStatus.getCode());
       addActionError(getText(ciJobStatus.getMessage()));
     } else {
       S_LOGGER.debug("Jenkins delete job status code " + ciJobStatus.getCode());
       addActionMessage(getText(ciJobStatus.getMessage()));
     }
     getHttpRequest().setAttribute("project", project);
   } catch (Exception e) {
     S_LOGGER.error(
         "Entered into catch block of CI.deleteCIJob()" + FrameworkUtil.getStackTraceAsString(e));
     new LogErrorReport(e, "Job delete");
   }
   getHttpRequest().setAttribute(REQ_SELECTED_MENU, APPLICATIONS);
   return ci();
 }