code: public Stage rerunFailedJobs(final Stage stage, final HttpOperationResult result) {
          final StageIdentifier identifier = stage.getIdentifier();
          JobInstances jobInstances = stage.jobsWithResult(JobResult.Cancelled, JobResult.Failed);
          List<String> jobNames = jobInstances.stream().map(JobInstance::getName).collect(Collectors.toList());
  
          if (jobNames.isEmpty()) {
              String message = "There are no failed jobs in the stage that could be re-run";
              result.badRequest(message, message, HealthStateType.general(HealthStateScope.forStage(identifier.getPipelineName(), identifier.getStageName())));
              return null;
          }
          return rerunJobs(stage, jobNames, result);
      }
docs: IMPORTANT: this method is only meant for TOP level usage(never use this within a transaction). It gobbles exception.