示例#1
0
 public void createRerunInstances(
     JobInstance oldJob,
     JobInstances jobInstances,
     SchedulingContext context,
     StageConfig stageConfig,
     final Clock clock,
     InstanceFactory instanceFactory) {
   String jobName = oldJob.getName();
   JobConfig jobConfig = stageConfig.jobConfigByInstanceName(jobName, true);
   if (jobConfig == null) {
     throw new CannotRerunJobException(jobName, "Configuration for job doesn't exist.");
   }
   if (jobConfig.isRunMultipleInstanceType()) {
     String runType = "'run multiple instance'";
     throw new CannotRerunJobException(
         jobName, "Run configuration for job has been changed to " + runType + ".");
   }
   RunOnAllAgents.CounterBasedJobNameGenerator nameGenerator =
       new RunOnAllAgents.CounterBasedJobNameGenerator(
           CaseInsensitiveString.str(jobConfig.name()));
   JobInstances instances =
       instanceFactory.createJobInstance(
           stageConfig.name(), jobConfig, context, clock, nameGenerator);
   for (JobInstance instance : instances) {
     instance.setRerun(true);
   }
   jobInstances.addAll(instances);
 }
示例#2
0
 public JobConfigIdentifier translateToActualCase(JobConfigIdentifier identifier) {
   PipelineConfig pipelineConfig =
       getCurrentConfig()
           .pipelineConfigByName(new CaseInsensitiveString(identifier.getPipelineName()));
   String translatedPipelineName = CaseInsensitiveString.str(pipelineConfig.name());
   StageConfig stageConfig =
       pipelineConfig.findBy(new CaseInsensitiveString(identifier.getStageName()));
   if (stageConfig == null) {
     throw new StageNotFoundException(
         new CaseInsensitiveString(identifier.getPipelineName()),
         new CaseInsensitiveString(identifier.getStageName()));
   }
   String translatedStageName = CaseInsensitiveString.str(stageConfig.name());
   JobConfig plan = stageConfig.jobConfigByInstanceName(identifier.getJobName(), true);
   if (plan == null) {
     throw new JobNotFoundException(
         identifier.getPipelineName(), identifier.getStageName(), identifier.getJobName());
   }
   String translatedJobName = plan.translatedName(identifier.getJobName());
   return new JobConfigIdentifier(translatedPipelineName, translatedStageName, translatedJobName);
 }