Пример #1
0
  private String buildStatusString(CurrentBuildResult results) {
    AdministrationConfiguration config =
        administrationConfigurationManager.getAdministrationConfiguration();

    String resultsUrl =
        config.getBaseUrl() + "/browse/" + buildContext.getPlanResultKey().toString();

    List<String> errors = results.getBuildErrors();

    if (!results.getBuildState().equals(BuildState.SUCCESS)) {
      if (errors != null && errors.size() > 0) {
        return textProvider.getText(
            "processor.gerrit.messages.build.custom", Arrays.asList(errors.toString(), resultsUrl));
      } else {
        return textProvider.getText(
            "processor.gerrit.messages.build.failed", Arrays.asList(resultsUrl));
      }
    }

    return textProvider.getText(
        "processor.gerrit.messages.build.sucess", Arrays.asList(resultsUrl));
  }
Пример #2
0
  /**
   * Attempts to retrieve the Sauce Session Id from the custom build data (it will be set if the
   * {@link com.saucelabs.bamboo.sod.action.PostBuildAction} class detects if the test output
   * contains a line starting with 'SauceOnDemandSessionID'). If the session id has not been set in
   * the custom build data, then we attempt to retrieve the job id via the Sauce REST API.
   *
   * <p>If a job id is found, then it is stored in the <code>jobId</code> instance variable, for use
   * by the sodView.ftl template. A HMAC token is also generated, which will be used to authenticate
   * the embedded job result requests.
   *
   * @return 'default'
   * @throws Exception thrown if an error occurs generating the key
   */
  @Override
  public String doDefault() throws Exception {
    String username, accessKey;
    logger.info("Processing ViewSODAction");

    jobInformation = new ArrayList<JobInformation>();

    ImmutablePlan plan = getImmutablePlan();
    if (plan instanceof ImmutableChain) {
      List<ImmutableChain> chains =
          cachedPlanManager.getPlansByProject(
              getImmutablePlan().getProject(), ImmutableChain.class);
      for (ImmutableJob job : ((ImmutableChain) plan).getAllJobs()) {
        final SODMappedBuildConfiguration config =
            new SODMappedBuildConfiguration(job.getBuildDefinition().getCustomConfiguration());
        if (StringUtils.isNotEmpty(config.getUsername())) {
          username = config.getUsername();
          accessKey = config.getAccessKey();
          jobInformation.addAll(retrieveJobIdsFromSauce(username, accessKey));
        }
        if (jobInformation.size() != 0) {
          break;
        }
      }
    }
    if (jobInformation.size() == 0) {
      AdministrationConfiguration adminConfig =
          administrationConfigurationManager.getAdministrationConfiguration();

      username = adminConfig.getSystemProperty(SODKeys.SOD_USERNAME_KEY);
      accessKey = adminConfig.getSystemProperty(SODKeys.SOD_ACCESSKEY_KEY);
      jobInformation.addAll(retrieveJobIdsFromSauce(username, accessKey));
    }

    return super.doDefault();
  }