Esempio n. 1
0
File: CI.java Progetto: ab-k/phresco
 public String buildProgress() {
   S_LOGGER.debug("Entering Method CI.buildProgress()");
   try {
     buildInProgress = false;
     String[] selectedJobs = getHttpRequest().getParameterValues(REQ_SELECTED_JOBS_LIST);
     S_LOGGER.debug("build progress jobs monitoring");
     ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
     Project project = administrator.getProject(projectCode);
     CIJob existJob = administrator.getJob(project);
     if (existJob != null) {
       boolean buildJenkinsAlive = false;
       buildJenkinsAlive =
           DiagnoseUtil.isConnectionAlive(
               "http", existJob.getJenkinsUrl(), Integer.parseInt(existJob.getJenkinsPort()));
       S_LOGGER.debug("Build jenkins alive " + buildJenkinsAlive);
       if (buildJenkinsAlive == true && administrator.getProgressInBuild(project) > 0) {
         buildInProgress = true;
       }
     }
   } catch (Exception e) {
     S_LOGGER.error(
         "Entered into catch block of CI.buildProgress()"
             + FrameworkUtil.getStackTraceAsString(e));
   }
   return SUCCESS;
 }
Esempio n. 2
0
File: CI.java Progetto: 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();
  }
Esempio n. 3
0
File: CI.java Progetto: ab-k/phresco
  public String setup() {
    if (debugEnabled) {
      S_LOGGER.debug("Entering Method  CI.setup()");
    }
    try {
      ProjectRuntimeManager runtimeManager = PhrescoFrameworkFactory.getProjectRuntimeManager();
      ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
      Project project = administrator.getProject(projectCode);
      ActionType actionType = ActionType.JENKINS_SETUP;
      actionType.setWorkingDirectory(Utility.getJenkinsHome());
      if (debugEnabled) {
        S_LOGGER.debug("Jenkins Home " + Utility.getJenkinsHome().toString());
      }

      // Here we have to place two files in jenkins_home environment variable location
      administrator.getJdkHomeXml();
      administrator.getMavenHomeXml();
      // place email ext plugin in plugin folder
      administrator.getEmailExtPlugin();
      BufferedReader reader = runtimeManager.performAction(project, actionType, null, null);
      getHttpSession().setAttribute(projectCode + CI_SETUP, reader);
      getHttpRequest().setAttribute(REQ_PROJECT_CODE, projectCode);
      getHttpRequest().setAttribute(REQ_TEST_TYPE, CI_SETUP);
    } catch (Exception e) {
      if (debugEnabled) {
        S_LOGGER.error(
            "Entered into catch block of CI.setup()" + FrameworkUtil.getStackTraceAsString(e));
      }
    }
    return APP_ENVIRONMENT_READER;
  }
Esempio n. 4
0
File: CI.java Progetto: ab-k/phresco
  public String ci() {
    S_LOGGER.debug("Entering Method CI.ci()");
    try {
      boolean jenkinsAlive = false;
      // UI didnt trigger anybuild from here
      getHttpRequest().setAttribute(CI_BUILD_TRIGGERED_FROM_UI, FALSE);
      ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
      Project project = (Project) administrator.getProject(projectCode);
      getHttpRequest().setAttribute(REQ_PROJECT, project);
      getHttpRequest().setAttribute(REQ_SELECTED_MENU, APPLICATIONS);
      getHttpRequest().setAttribute(CI_JENKINS_ALIVE, jenkinsAlive);

      jenkinsAlive =
          DiagnoseUtil.isConnectionAlive(
              HTTP_PROTOCOL, LOCALHOST, Integer.parseInt(getPortNo(Utility.getJenkinsHome())));
      S_LOGGER.debug("jenkins Alive " + jenkinsAlive);
      getHttpRequest().setAttribute(CI_JENKINS_ALIVE, jenkinsAlive);

      List<CIJob> existingJobs = administrator.getJobs(project);
      Map<String, List<CIBuild>> ciJobsAndBuilds = new HashMap<String, List<CIBuild>>();
      if (existingJobs != null) {
        for (CIJob ciJob : existingJobs) {
          boolean buildJenkinsAlive = false;
          boolean isJobCreatingBuild = false;
          int noOfJobsIsInProgress = 0;
          List<CIBuild> builds = null;
          buildInProgress = false;
          buildJenkinsAlive =
              DiagnoseUtil.isConnectionAlive(
                  HTTP_PROTOCOL, ciJob.getJenkinsUrl(), Integer.parseInt(ciJob.getJenkinsPort()));
          isJobCreatingBuild = administrator.isJobCreatingBuild(ciJob);
          S_LOGGER.debug("ciJob.getName() ====> " + ciJob.getName());
          S_LOGGER.debug("ciJob.getName() alive  ====> " + buildJenkinsAlive);
          S_LOGGER.debug("ciJob.getName() isJobCreatingBuild  ====> " + isJobCreatingBuild);
          getHttpRequest()
              .setAttribute(CI_BUILD_JENKINS_ALIVE + ciJob.getName(), buildJenkinsAlive);
          getHttpRequest()
              .setAttribute(CI_BUILD_IS_IN_PROGRESS + ciJob.getName(), isJobCreatingBuild);
          if (buildJenkinsAlive == true) {
            builds = administrator.getBuilds(ciJob);
          }
          S_LOGGER.debug("ciJob.getName() builds ====> " + builds);
          ciJobsAndBuilds.put(ciJob.getName(), builds);
        }
      }
      getHttpRequest().setAttribute(REQ_EXISTING_JOBS, ciJobsAndBuilds);
      numberOfJobsIsInProgress();
      S_LOGGER.debug("numberOfJobsInProgress " + numberOfJobsInProgress);
      getHttpRequest().setAttribute(CI_NO_OF_JOBS_IN_PROGRESS, numberOfJobsInProgress);
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into catch block of CI.ci()" + FrameworkUtil.getStackTraceAsString(e));
    }
    return APP_CI;
  }
Esempio n. 5
0
  public String createReportConfig() {
    S_LOGGER.debug("Entering Method  SiteReport.createReportConfig()");

    try {
      ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
      ProjectInfo projectInfo = administrator.getProject(projectCode).getProjectInfo();

      // To get the selected reports from the UI
      String[] arraySelectedReports = getHttpRequest().getParameterValues(REQ_SITE_REPORTS);
      List<String> selectedReports = null;
      if (!ArrayUtils.isEmpty(arraySelectedReports)) {
        selectedReports = Arrays.asList(arraySelectedReports);
      }

      // To get the selected ReportCategories from the UI
      String[] arraySelectedRptCategories =
          getHttpRequest().getParameterValues(REQ_SITE_SLECTD_REPORTSCATEGORIES);
      List<ReportCategories> selectedReportCategories = new ArrayList<ReportCategories>();
      if (!ArrayUtils.isEmpty(arraySelectedRptCategories)) {
        for (String arraySelectedRptCategory : arraySelectedRptCategories) {
          ReportCategories cat = new ReportCategories();
          cat.setName(arraySelectedRptCategory);
          selectedReportCategories.add(cat);
        }
      }

      // To get the list of Reports to be added
      List<Reports> allReports = administrator.getReports(projectInfo);
      List<Reports> reportsToBeAdded = new ArrayList<Reports>();
      if (CollectionUtils.isNotEmpty(selectedReports) && CollectionUtils.isNotEmpty(allReports)) {
        for (Reports report : allReports) {
          if (selectedReports.contains(report.getArtifactId())) {
            reportsToBeAdded.add(report);
          }
        }
      }

      administrator.updateRptPluginInPOM(projectInfo, reportsToBeAdded, selectedReportCategories);
      addActionMessage(getText(SUCCESS_SITE_CONFIGURE));
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into catch block of SiteReport.createReportConfig()"
              + FrameworkUtil.getStackTraceAsString(e));
      new LogErrorReport(e, "Configuring site report");
    }

    return viewSiteReport();
  }
Esempio n. 6
0
File: CI.java Progetto: ab-k/phresco
 public String getTotalBuilds() {
   if (debugEnabled) {
     S_LOGGER.debug("Entering Method  CI.getTotalBuilds()");
   }
   try {
     ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
     Project project = administrator.getProject(projectCode);
     totalBuildSize =
         administrator.getTotalBuilds(
             project); // when getting all the builds , it ll try to get all build status, so it ll
     // return -1.
   } catch (Exception e) {
     totalBuildSize = -1;
   }
   return "success";
 }
Esempio n. 7
0
  public String viewSiteReport() {
    S_LOGGER.debug("Entering Method  SiteReport.viewSiteReport()");

    try {
      ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
      ProjectInfo projectInfo = administrator.getProject(projectCode).getProjectInfo();
      List<Reports> selectedReports = administrator.getPomReports(projectInfo);
      getHttpRequest().setAttribute(REQ_SITE_SLECTD_REPORTS, selectedReports);
      getHttpRequest().setAttribute(REQ_PROJECT_CODE, projectCode);
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into catch block of SiteReport.viewSiteReport()"
              + FrameworkUtil.getStackTraceAsString(e));
      new LogErrorReport(e, "View site report");
    }

    return APP_SITE_REPORT_VIEW;
  }
Esempio n. 8
0
File: CI.java Progetto: ab-k/phresco
 public String CIBuildDownload() {
   S_LOGGER.debug("Entering Method CI.CIBuildDownload()");
   try {
     ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
     Project project = administrator.getProject(projectCode);
     CIJob existJob = administrator.getJob(project, downloadJobName);
     // Get it from web path
     URL url = new URL(buildDownloadUrl);
     S_LOGGER.debug("Entering Method CI.CIBuildDownload() buildDownloadUrl " + buildDownloadUrl);
     fileInputStream = url.openStream();
     fileName = existJob.getName();
     return SUCCESS;
   } catch (Exception e) {
     S_LOGGER.error(
         "Entered into catch block of CI.CIBuildDownload()"
             + FrameworkUtil.getStackTraceAsString(e));
   }
   return SUCCESS;
 }
Esempio n. 9
0
File: CI.java Progetto: ab-k/phresco
  public String stopJenkins() {
    S_LOGGER.debug("Entering Method  CI.stopJenkins()");
    try {
      ProjectRuntimeManager runtimeManager = PhrescoFrameworkFactory.getProjectRuntimeManager();
      ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
      Project project = administrator.getProject(projectCode);
      ActionType actionType = ActionType.JENKINS_STOP;
      actionType.setWorkingDirectory(Utility.getJenkinsHome());
      S_LOGGER.debug("Jenkins Home " + Utility.getJenkinsHome().toString());
      BufferedReader reader = runtimeManager.performAction(project, actionType, null, null);

      getHttpSession().setAttribute(projectCode + CI_STOP, reader);
      getHttpRequest().setAttribute(REQ_PROJECT_CODE, projectCode);
      getHttpRequest().setAttribute(REQ_TEST_TYPE, CI_STOP);
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into catch block of CI.stopJenkins()" + FrameworkUtil.getStackTraceAsString(e));
    }
    return APP_ENVIRONMENT_READER;
  }
Esempio n. 10
0
File: CI.java Progetto: ab-k/phresco
 public String numberOfJobsIsInProgress() {
   S_LOGGER.debug("Entering Method CI.numberOfJobsIsInProgress()");
   try {
     S_LOGGER.debug("numberOfJobsIsInProgress jobs monitoring");
     ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
     Project project = administrator.getProject(projectCode);
     List<CIJob> jobs = administrator.getJobs(project);
     if (CollectionUtils.isNotEmpty(jobs)) {
       for (CIJob ciJob : jobs) {
         boolean jobCreatingBuild = administrator.isJobCreatingBuild(ciJob);
         if (jobCreatingBuild) {
           numberOfJobsInProgress++;
         }
       }
     }
   } catch (Exception e) {
     S_LOGGER.error(
         "Entered into catch block of CI.buildProgress()"
             + FrameworkUtil.getStackTraceAsString(e));
   }
   return SUCCESS;
 }
Esempio n. 11
0
File: CI.java Progetto: ab-k/phresco
  public String configure() {
    S_LOGGER.debug("Entering Method  CI.configure()");
    try {
      String[] selectedJobsName = getHttpRequest().getParameterValues(REQ_SELECTED_JOBS_LIST);
      String jobName = "";
      if (!ArrayUtils.isEmpty(selectedJobsName)) {
        jobName = selectedJobsName[0];
      }
      S_LOGGER.debug("selectedJobs for configuration " + jobName);

      ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
      Project project = administrator.getProject(projectCode);
      // Get environment info
      List<Environment> environments = administrator.getEnvironments(project);
      getHttpRequest().setAttribute(REQ_ENVIRONMENTS, environments);
      getHttpRequest().setAttribute(REQ_PROJECT, project);
      // Get xcode targets
      String technology = project.getProjectInfo().getTechnology().getId();
      if (TechnologyTypes.IPHONES.contains(technology)) {
        List<PBXNativeTarget> xcodeConfigs = ApplicationsUtil.getXcodeConfiguration(projectCode);
        getHttpRequest().setAttribute(REQ_XCODE_CONFIGS, xcodeConfigs);
        // get list of sdks
        List<String> iphoneSdks = IosSdkUtil.getMacSdks(MacSdkType.iphoneos);
        iphoneSdks.addAll(IosSdkUtil.getMacSdks(MacSdkType.iphonesimulator));
        iphoneSdks.addAll(IosSdkUtil.getMacSdks(MacSdkType.macosx));
        getHttpRequest().setAttribute(REQ_IPHONE_SDKS, iphoneSdks);
      }
      CIJob existJob = administrator.getJob(project, jobName);
      existJob.setCollabNetpassword(CIPasswordScrambler.unmask(existJob.getCollabNetpassword()));
      getHttpRequest().setAttribute(REQ_EXISTING_JOB, existJob);
      getHttpRequest().setAttribute(REQ_SELECTED_MENU, APPLICATIONS);
      getHttpRequest().setAttribute(REQ_PROJECT_CODE, projectCode);
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into catch block of CI.configure()" + FrameworkUtil.getStackTraceAsString(e));
      new LogErrorReport(e, "CI configuration clicked");
    }
    return APP_CI_CONFIGURE;
  }
Esempio n. 12
0
  public String generateSiteReport() {
    S_LOGGER.debug("Entering Method  SiteReport.generateReport()");

    try {
      ActionType actionType = null;
      ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
      Project project = administrator.getProject(projectCode);
      ProjectRuntimeManager runtimeManager = PhrescoFrameworkFactory.getProjectRuntimeManager();
      actionType = ActionType.SITE_REPORT;
      actionType.setWorkingDirectory(null);
      BufferedReader reader = runtimeManager.performAction(project, actionType, null, null);
      getHttpSession().setAttribute(projectCode + REQ_SITE_REPORT, reader);
      getHttpRequest().setAttribute(REQ_PROJECT_CODE, projectCode);
      getHttpRequest().setAttribute(REQ_TEST_TYPE, REQ_SITE_REPORT);
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into catch block of SiteReport.generateSiteReport()"
              + FrameworkUtil.getStackTraceAsString(e));
      new LogErrorReport(e, "Generating site report");
    }

    return APP_ENVIRONMENT_READER;
  }
Esempio n. 13
0
File: CI.java Progetto: ab-k/phresco
  public String doUpdateSave(String jobType) {
    S_LOGGER.debug("Entering Method  CI.doUpdateSave()");
    try {
      ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
      Project project = administrator.getProject(projectCode);
      String technology = project.getProjectInfo().getTechnology().getId();
      CIJob existJob = null;
      if (StringUtils.isNotEmpty(oldJobName)) {
        existJob = administrator.getJob(project, oldJobName);
      }
      if (existJob == null) {
        existJob = new CIJob();
      }
      InetAddress thisIp = InetAddress.getLocalHost();
      existJob.setName(name);
      existJob.setSvnUrl(svnurl);
      existJob.setUserName(username);
      existJob.setPassword(CIPasswordScrambler.mask(password));
      existJob.setJenkinsUrl(thisIp.getHostAddress());
      existJob.setJenkinsPort(getPortNo(Utility.getJenkinsHome()));
      existJob.setTriggers(triggers);
      Map<String, String> emails = new HashMap<String, String>(2);
      emails.put(REQ_KEY_SUCCESS_EMAILS, successEmailIds);
      emails.put(REQ_KEY_FAILURE_EMAILS, failureEmailIds);

      Map<String, String> settingsInfoMap = new HashMap<String, String>(2);
      ActionType actionType = null;

      // For web technologies
      if (StringUtils.isNotEmpty(environment)) {
        settingsInfoMap.put(ENVIRONMENT_NAME, environment);
      }

      // For android technologies
      if (StringUtils.isNotEmpty(androidVersion)) {
        settingsInfoMap.put(AndroidConstants.ANDROID_VERSION_MVN_PARAM, androidVersion);
      }

      // For iphone technoloies
      if (TechnologyTypes.IPHONES.contains(technology)) {
        settingsInfoMap.put(IPHONE_SDK, sdk);
        settingsInfoMap.put(IPHONE_CONFIGURATION, mode);
        settingsInfoMap.put(IPHONE_TARGET_NAME, target);
        if (TechnologyTypes.IPHONE_HYBRID.equals(technology)) {
          settingsInfoMap.put(IPHONE_PLISTFILE, XCodeConstants.HYBRID_PLIST);
          settingsInfoMap.put(ENCRYPT, FALSE);
        } else if (TechnologyTypes.IPHONE_NATIVE.equals(technology)) {
          settingsInfoMap.put(IPHONE_PLISTFILE, XCodeConstants.NATIVE_PLIST);
          settingsInfoMap.put(ENCRYPT, TRUE);
        }
      }

      // For mobile technologies
      if (TechnologyTypes.ANDROIDS.contains(technology)) {
        if (StringUtils.isEmpty(proguard)) {
          // if the checkbox is selected value should be set to false otherwise true
          proguard = TRUE;
        }
        settingsInfoMap.put(ANDROID_PROGUARD_SKIP, proguard);
        actionType = ActionType.MOBILE_COMMON_COMMAND;
        if (StringUtils.isNotEmpty(signing)) {
          actionType.setProfileId(PROFILE_ID);
        }
      } else if (TechnologyTypes.IPHONES.contains(technology)) {
        actionType = ActionType.IPHONE_BUILD_UNIT_TEST;
      } else {
        actionType = ActionType.BUILD;
      }
      ProjectRuntimeManager runtimeManager = PhrescoFrameworkFactory.getProjectRuntimeManager();
      String mvncmd = "";
      StringBuilder command = actionType.getCommand();
      StringBuilder buildMavenCommand = new StringBuilder();
      if (command == null) {
        buildMavenCommand = runtimeManager.buildMavenCommand(project, actionType, settingsInfoMap);
      } else {
        buildMavenCommand.append(command);
        buildMavenCommand.append(SPACE);
        buildMavenCommand.append(runtimeManager.buildMavenArgCommand(actionType, settingsInfoMap));
      }
      mvncmd = buildMavenCommand.toString().substring(4).trim();
      mvncmd = CI_PROFILE + mvncmd;
      S_LOGGER.debug("mvn command " + mvncmd);
      existJob.setMvnCommand(mvncmd);
      existJob.setEmail(emails);
      existJob.setScheduleType(schedule);
      existJob.setScheduleExpression(cronExpression);
      existJob.setSenderEmailId(senderEmailId);
      existJob.setSenderEmailPassword(senderEmailPassword);
      existJob.setBranch(branch);
      existJob.setRepoType(svnType);
      // collabNet file release plugin imple
      existJob.setEnableBuildRelease(enableBuildRelease);
      existJob.setCollabNetURL(collabNetURL);
      existJob.setCollabNetusername(collabNetusername);
      existJob.setCollabNetpassword(CIPasswordScrambler.mask(collabNetpassword));
      existJob.setCollabNetProject(collabNetProject);
      existJob.setCollabNetPackage(collabNetPackage);
      existJob.setCollabNetRelease(collabNetRelease);
      existJob.setCollabNetoverWriteFiles(collabNetoverWriteFiles);

      if (CI_CREATE_JOB_COMMAND.equals(jobType)) {
        administrator.createJob(project, existJob);
        addActionMessage(getText(SUCCESS_JOB));
      } else if (CI_UPDATE_JOB_COMMAND.equals(jobType)) {
        administrator.updateJob(project, existJob);
        addActionMessage(getText(SUCCESS_UPDATE));
      }

      restartJenkins(); // TODO: reload config

      getHttpRequest().setAttribute(REQ_SELECTED_MENU, APPLICATIONS);
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into catch block of CI.doUpdateSave()" + FrameworkUtil.getStackTraceAsString(e));
      addActionMessage(getText(CI_SAVE_UPDATE_FAILED, e.getLocalizedMessage()));
    }

    return ci();
  }