コード例 #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 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();
  }
コード例 #3
0
ファイル: CI.java プロジェクト: 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;
 }
コード例 #4
0
 @Override
 public String getCiSvnPath() throws PhrescoException {
   Client client = ClientHelper.createClient();
   FrameworkConfiguration configuration = PhrescoFrameworkFactory.getFrameworkConfig();
   WebResource resource =
       client.resource(configuration.getServerPath() + FrameworkConstants.REST_CI_SVN_PATH);
   return resource.accept(MediaType.TEXT_PLAIN).get(String.class);
 }
コード例 #5
0
  private void initCache() throws PhrescoException {
    if (debugEnabled) {
      S_LOGGER.debug("Entering Method ServiceManagerImpl.initCache()");
    }
    List<ApplicationType> apptypes = null;
    List<VideoInfo> videoInfos = null;
    List<SettingsTemplate> settingsTemplate = null;
    List<Environment> enveInfo = null;

    if (PhrescoFrameworkFactory.getFrameworkConfig().isCacheEnabled()) {
      apptypes = loadAppTypesFromFile();
      videoInfos = loadVideosFromFile();
      settingsTemplate = loadSettingsTemplateFromFile();
    }

    // Load AppTypes into Cache
    if (apptypes == null) {
      apptypes = getApplicationTypesFromServer();
    }

    // Load Videos into Cache
    if (videoInfos == null) {
      videoInfos = loadVideosFromService();
    }

    // Load Settings into Cache
    if (settingsTemplate == null) {
      settingsTemplate = loadSettingsTemplateFromService();
    }

    if (enveInfo == null) {
      enveInfo = getEnvInfoFromService();
    }

    if (PhrescoFrameworkFactory.getFrameworkConfig().isCacheEnabled()) {
      writeToFile(VIDEOS_FILE, videoInfos);
      writeToFile(APPTYPES_FILE, apptypes);
      writeToFile(SETTINGS_FILE, settingsTemplate);
    }

    cache.add(APPTYPES_FILE, apptypes);
    cache.add(VIDEOS_FILE, videoInfos);
    cache.add(SETTINGS_FILE, settingsTemplate);
  }
コード例 #6
0
ファイル: CI.java プロジェクト: 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;
  }
コード例 #7
0
 private List<ApplicationType> getApplicationTypesFromServer() throws PhrescoException {
   if (debugEnabled) {
     S_LOGGER.debug("Entering Method ServiceManagerImpl.getApplicationTypesFromServer()");
   }
   FrameworkConfiguration configuration = PhrescoFrameworkFactory.getFrameworkConfig();
   Client client = ClientHelper.createClient();
   WebResource resource = client.resource(configuration.getServerPath() + REST_APPS_PATH);
   Builder builder = resource.accept(MediaType.APPLICATION_JSON_TYPE);
   GenericType<List<ApplicationType>> genericType = new GenericType<List<ApplicationType>>() {};
   return builder.get(genericType);
 }
コード例 #8
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;
  }
コード例 #9
0
 @Override
 public List<Reports> getReports(String techId) throws PhrescoException {
   Client client = ClientHelper.createClient();
   FrameworkConfiguration configuration = PhrescoFrameworkFactory.getFrameworkConfig();
   WebResource resource =
       client.resource(
           configuration.getServerPath() + FrameworkConstants.REST_REPORTS + "/" + techId);
   Builder builder = resource.accept(MediaType.APPLICATION_JSON);
   GenericType<List<Reports>> genericType = new GenericType<List<Reports>>() {};
   List<Reports> reportList = builder.get(genericType);
   return reportList;
 }
コード例 #10
0
  public List<Environment> getEnvInfoFromService() throws PhrescoException {
    if (debugEnabled) {
      S_LOGGER.debug("Entering Method ServiceManagerImpl.getEnvFromService()");
    }
    Client client = ClientHelper.createClient();
    FrameworkConfiguration frameworkConfig = PhrescoFrameworkFactory.getFrameworkConfig();
    WebResource resource = client.resource(frameworkConfig.getServerPath() + REST_ENVE_PATH);
    Builder builder = resource.accept(MediaType.APPLICATION_JSON_TYPE);

    GenericType<List<Environment>> genericType = new GenericType<List<Environment>>() {};
    return builder.get(genericType);
  }
コード例 #11
0
  public ClientResponse getEmailExtPlugin() throws PhrescoException {
    if (debugEnabled) {
      S_LOGGER.debug("Entering Method ServiceManagerImpl.getEmailExtPlugin");
    }

    Client client = ClientHelper.createClient();
    FrameworkConfiguration configuration = PhrescoFrameworkFactory.getFrameworkConfig();
    WebResource resource =
        client.resource(configuration.getServerPath() + FrameworkConstants.REST_CI_MAIL_PLUGIN);
    resource.accept(MediaType.APPLICATION_OCTET_STREAM);
    ClientResponse response = resource.get(ClientResponse.class);
    return response;
  }
コード例 #12
0
 @Override
 public ClientResponse sendReport(LogInfo loginfo) throws PhrescoException {
   if (debugEnabled) {
     S_LOGGER.debug("Entering Method ServiceManagerImpl.sendReport(LogInfo loginfo)");
   }
   Client client = ClientHelper.createClient();
   FrameworkConfiguration configuration = PhrescoFrameworkFactory.getFrameworkConfig();
   WebResource resource =
       client.resource(configuration.getServerPath() + FrameworkConstants.REST_LOG_PATH);
   ClientResponse response =
       resource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, loginfo);
   return response;
 }
コード例 #13
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;
  }
コード例 #14
0
  public InputStream getMailerXml() throws PhrescoException {
    if (debugEnabled) {
      S_LOGGER.debug("Entering Method ServiceManagerImpl.getMailerXml");
    }

    Client client = ClientHelper.createClient();
    FrameworkConfiguration configuration = PhrescoFrameworkFactory.getFrameworkConfig();
    WebResource resource =
        client.resource(configuration.getServerPath() + FrameworkConstants.REST_CI_MAILER_HOME);
    resource.accept(MediaType.APPLICATION_XML);
    ClientResponse response = resource.type(MediaType.APPLICATION_XML).get(ClientResponse.class);
    InputStream is = response.getEntityInputStream();
    return is;
  }
コード例 #15
0
 @Override
 public List<AdminConfigInfo> getAdminConfig() throws PhrescoException {
   if (debugEnabled) {
     S_LOGGER.debug("Entering Method ServiceManagerImpl.getAdminConfig()");
   }
   Client client = ClientHelper.createClient();
   FrameworkConfiguration configuration = PhrescoFrameworkFactory.getFrameworkConfig();
   WebResource resource =
       client.resource(configuration.getServerPath() + FrameworkConstants.REST_ADMIN_CONFIG_PATH);
   resource.accept(MediaType.APPLICATION_JSON_TYPE);
   ClientResponse clientResponse =
       resource.type(MediaType.APPLICATION_JSON_TYPE).get(ClientResponse.class);
   GenericType<List<AdminConfigInfo>> genericType = new GenericType<List<AdminConfigInfo>>() {};
   return clientResponse.getEntity(genericType);
 }
コード例 #16
0
 public User doLogin(Credentials credentials) throws PhrescoException {
   if (debugEnabled) {
     S_LOGGER.debug("Entering Method ServiceManagerImpl.doLogin(Credentials credentials)");
   }
   Client client = ClientHelper.createClient();
   FrameworkConfiguration configuration = PhrescoFrameworkFactory.getFrameworkConfig();
   WebResource resource =
       client.resource(configuration.getServerPath() + FrameworkConstants.REST_LOGIN_PATH);
   resource.accept(MediaType.APPLICATION_JSON_TYPE);
   ClientResponse response =
       resource.type(MediaType.APPLICATION_JSON_TYPE).post(ClientResponse.class, credentials);
   GenericType<User> genericType = new GenericType<User>() {};
   User userInfo = response.getEntity(genericType);
   return userInfo;
 }
コード例 #17
0
ファイル: CIManagerImpl.java プロジェクト: manoj-s/framework
 public BufferedReader stop(
     ProjectInfo projectInfo,
     ActionType action,
     List<String> buildArgCmds,
     String workingDirectory)
     throws PhrescoException {
   try {
     ApplicationManager applicationManager = PhrescoFrameworkFactory.getApplicationManager();
     BufferedReader reader =
         applicationManager.performAction(projectInfo, action, buildArgCmds, workingDirectory);
     return reader;
   } catch (Exception e) {
     throw new PhrescoException(e);
   }
 }
コード例 #18
0
ファイル: SiteReport.java プロジェクト: ab-k/phresco
  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();
  }
コード例 #19
0
ファイル: CI.java プロジェクト: 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";
 }
コード例 #20
0
 public List<DownloadInfo> getDownloadsFromService(DownloadPropertyInfo downloadPropertyInfo)
     throws PhrescoException {
   if (debugEnabled) {
     S_LOGGER.debug("Entering Method ServiceManagerImpl.loadVideosFromService()");
   }
   FrameworkConfiguration configuration = PhrescoFrameworkFactory.getFrameworkConfig();
   Client client = ClientHelper.createClient();
   WebResource resource = client.resource(configuration.getServerPath() + REST_DOWNLOADS_PATH);
   ClientResponse response =
       resource
           .type(MediaType.APPLICATION_JSON_TYPE)
           .post(ClientResponse.class, downloadPropertyInfo);
   GenericType<List<DownloadInfo>> genericType = new GenericType<List<DownloadInfo>>() {};
   List<DownloadInfo> downloadInfo = response.getEntity(genericType);
   return downloadInfo;
 }
コード例 #21
0
 public ClientResponse updateDocumentProject(ProjectInfo info) throws PhrescoException {
   if (debugEnabled) {
     S_LOGGER.debug("Entering Method ServiceManagerImpl.updateProject(ProjectInfo info)");
   }
   Client client = ClientHelper.createClient();
   FrameworkConfiguration configuration = PhrescoFrameworkFactory.getFrameworkConfig();
   WebResource resource =
       client.resource(
           configuration.getServerPath() + FrameworkConstants.REST_APPS_UPDATEDOC_PATH);
   resource.accept(MediaType.APPLICATION_OCTET_STREAM);
   if (debugEnabled) {
     S_LOGGER.debug("updateDocumentProject() ProjectName = " + info.getName());
   }
   ClientResponse response =
       resource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, info);
   return response;
 }
コード例 #22
0
ファイル: SiteReport.java プロジェクト: ab-k/phresco
  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;
  }
コード例 #23
0
ファイル: CI.java プロジェクト: 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;
 }
コード例 #24
0
 public ClientResponse createProject(ProjectInfo info, User userInfo) throws PhrescoException {
   if (debugEnabled) {
     S_LOGGER.debug("Entering Method ServiceManagerImpl.createProject(ProjectInfo info)");
   }
   Client client = ClientHelper.createClient();
   FrameworkConfiguration configuration = PhrescoFrameworkFactory.getFrameworkConfig();
   WebResource resource =
       client.resource(configuration.getServerPath() + FrameworkConstants.REST_APPS_PATH);
   resource.accept(MediaType.APPLICATION_OCTET_STREAM);
   if (debugEnabled) {
     S_LOGGER.debug("createProject() ProjectName = " + info.getName());
   }
   ClientResponse response =
       resource
           .header(Constants.AUTH_TOKEN, userInfo.getToken())
           .type(MediaType.APPLICATION_JSON)
           .post(ClientResponse.class, info);
   //        reSetCacheAppTypes();
   return response;
 }
コード例 #25
0
ファイル: CI.java プロジェクト: 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;
 }
コード例 #26
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;
  }
コード例 #27
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();
  }