コード例 #1
0
ファイル: CI.java プロジェクト: 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;
  }
コード例 #2
0
ファイル: CI.java プロジェクト: 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;
  }
コード例 #3
0
ファイル: SiteReport.java プロジェクト: ab-k/phresco
  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;
  }
コード例 #4
0
ファイル: CI.java プロジェクト: 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();
  }