/**
  * Entry point into build action.
  *
  * @return
  */
 @NotNull
 // @Override
 public BuildContext call() {
   final SODMappedBuildConfiguration config =
       new SODMappedBuildConfiguration(buildContext.getBuildDefinition().getCustomConfiguration());
   if (config.isEnabled()) {
     setSeleniumEnvironmentVars(config);
   }
   return buildContext;
 }
  /**
   * 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();
  }