示例#1
0
文件: CI.java 项目: 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;
  }
示例#2
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();
  }