Exemplo n.º 1
0
 /** 调用Getter方法. 支持多级,如:对象名.对象名.方法 */
 public static Object invokeGetter(Object obj, String propertyName) {
   Object object = obj;
   for (String name : StringUtils.split(propertyName, ".")) {
     String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name);
     object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
   }
   return object;
 }
Exemplo n.º 2
0
 /** 调用Setter方法, 仅匹配方法名。 支持多级,如:对象名.对象名.方法 */
 public static void invokeSetter(Object obj, String propertyName, Object value) {
   Object object = obj;
   String[] names = StringUtils.split(propertyName, ".");
   for (int i = 0; i < names.length; i++) {
     if (i < names.length - 1) {
       String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]);
       object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
     } else {
       String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]);
       invokeMethodByName(object, setterMethodName, new Object[] {value});
     }
   }
 }
Exemplo n.º 3
0
 public CIJob getJob(ApplicationInfo appInfo, String jobName) throws PhrescoException {
   try {
     S_LOGGER.debug("Search for jobName => " + jobName);
     if (StringUtils.isEmpty(jobName)) {
       return null;
     }
     List<CIJob> jobs = getJobs(appInfo);
     if (CollectionUtils.isEmpty(jobs)) {
       S_LOGGER.debug("job list is empty!!!!!!!!");
       return null;
     }
     S_LOGGER.debug("Job list found!!!!!");
     for (CIJob job : jobs) {
       S_LOGGER.debug("job list job Names => " + job.getName());
       if (job.getName().equals(jobName)) {
         return job;
       }
     }
   } catch (Exception e) {
     throw new PhrescoException(e);
   }
   return null;
 }
Exemplo n.º 4
0
  private void customizeNodes(ConfigProcessor processor, CIJob job)
      throws JDOMException, PhrescoException {

    // SVN url customization
    if (SVN.equals(job.getRepoType())) {
      S_LOGGER.debug("This is svn type project!!!!!");
      processor.changeNodeValue(SCM_LOCATIONS_REMOTE, job.getSvnUrl());
    } else if (GIT.equals(job.getRepoType())) {
      S_LOGGER.debug("This is git type project!!!!!");
      processor.changeNodeValue(SCM_USER_REMOTE_CONFIGS_URL, job.getSvnUrl());
      processor.changeNodeValue(SCM_BRANCHES_NAME, job.getBranch());
      // cloned workspace
    } else if (CLONED_WORKSPACE.equals(job.getRepoType())) {
      S_LOGGER.debug("Clonned workspace selected!!!!!!!!!!");
      processor.useClonedScm(job.getUsedClonnedWorkspace(), SUCCESSFUL);
    }

    // Schedule expression customization
    processor.changeNodeValue(TRIGGERS_SPEC, job.getScheduleExpression());

    // Triggers Implementation
    List<String> triggers = job.getTriggers();

    processor.createTriggers(TRIGGERS, triggers, job.getScheduleExpression());

    // if the technology is java stanalone and functional test , goal have to specified in post
    // build step only
    if (job.isEnablePostBuildStep() && FUNCTIONAL_TEST.equals(job.getOperation())) {
      // Maven command customization
      processor.changeNodeValue(GOALS, CI_FUNCTIONAL_ADAPT.trim());
    } else {
      // Maven command customization
      processor.changeNodeValue(GOALS, job.getMvnCommand());
    }

    // Recipients customization
    Map<String, String> email = job.getEmail();

    // Failure Reception list
    processor.changeNodeValue(
        TRIGGER_FAILURE_EMAIL_RECIPIENT_LIST, (String) email.get(FAILURE_EMAILS));

    // Success Reception list
    processor.changeNodeValue(
        TRIGGER_SUCCESS__EMAIL_RECIPIENT_LIST, (String) email.get(SUCCESS_EMAILS));

    // enable collabnet file release plugin integration
    if (job.isEnableBuildRelease()) {
      S_LOGGER.debug("Enablebling collabnet file release plugin ");
      processor.enableCollabNetBuildReleasePlugin(job);
    }

    // use clonned scm
    if (CLONED_WORKSPACE.equals(job.getRepoType())) {
      S_LOGGER.debug("using cloned workspace ");
      processor.useClonedScm(job.getUsedClonnedWorkspace(), SUCCESSFUL);
    }

    // clone workspace for future use
    if (job.isCloneWorkspace()) {
      S_LOGGER.debug("Clonning the workspace ");
      processor.cloneWorkspace(ALL_FILES, SUCCESSFUL, TAR);
    }

    // Build Other projects
    if (StringUtils.isNotEmpty(job.getDownStreamProject())) {
      S_LOGGER.debug("Enabling downstream project!!!!!!");
      processor.buildOtherProjects(job.getDownStreamProject());
    }

    // pom location specifier
    if (StringUtils.isNotEmpty(job.getPomLocation())) {
      S_LOGGER.debug("POM location changing " + job.getPomLocation());
      processor.updatePOMLocation(job.getPomLocation());
    }

    if (job.isEnablePostBuildStep()) {
      System.out.println("java stanalone technology with functional test enabled!!!!!!!");
      String mvnCommand = job.getMvnCommand();
      String[] ciAdapted =
          mvnCommand.split(CI_FUNCTIONAL_ADAPT); // java stanalone functional test alone
      for (String ciCommand : ciAdapted) {
        S_LOGGER.debug("ciCommand...." + ciCommand);
      }
      // iterate over loop
      processor.enablePostBuildStep(job.getPomLocation(), ciAdapted[1]);
    }

    if (job.isEnablePreBuildStep()) {
      System.out.println("java stanalone technology with functional test enabled!!!!!!!");
      // iterate over loop
      List<String> prebuildStepCommands = job.getPrebuildStepCommands();
      for (String prebuildStepCommand : prebuildStepCommands) {
        processor.enablePreBuildStep(job.getPomLocation(), prebuildStepCommand);
      }
    }
  }