Exemplo n.º 1
0
 public Pipeline schedulePipeline(
     PipelineConfig pipelineConfig, BuildCause buildCause, String approvedBy, final Clock clock) {
   Pipeline pipeline =
       instanceFactory.createPipelineInstance(
           pipelineConfig, buildCause, new DefaultSchedulingContext(approvedBy), md5, clock);
   return scheduleJobInstancesAndSavePipeline(pipeline);
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
 public Pipeline schedulePipelineWithAllStages(
     PipelineConfig pipelineConfig, BuildCause buildCause) {
   buildCause.assertMaterialsMatch(pipelineConfig.materialConfigs());
   DefaultSchedulingContext defaultSchedulingContext =
       new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY);
   Stages stages = new Stages();
   Pipeline pipeline =
       instanceFactory.createPipelineInstance(
           pipelineConfig, buildCause, defaultSchedulingContext, md5, new TimeProvider());
   for (StageConfig stageConfig : pipelineConfig) {
     stages.add(
         instanceFactory.createStageInstance(
             stageConfig, defaultSchedulingContext, md5, new TimeProvider()));
   }
   pipeline.setStages(stages);
   return scheduleJobInstancesAndSavePipeline(pipeline);
 }
Exemplo n.º 4
0
 public Pipeline checkinRevisionsToBuild(
     ManualBuild build, PipelineConfig pipelineConfig, List<MaterialRevision> revisions) {
   return pipelineService.save(
       instanceFactory.createPipelineInstance(
           pipelineConfig,
           build.onModifications(new MaterialRevisions(revisions), false, null),
           new DefaultSchedulingContext(),
           "md5-test",
           new TimeProvider()));
 }
Exemplo n.º 5
0
 private Pipeline scheduleWithFileChanges(PipelineConfig pipelineConfig) {
   BuildCause buildCause = BuildCause.createWithModifications(modifyOneFile(pipelineConfig), "");
   saveRevs(buildCause.getMaterialRevisions());
   return instanceFactory.createPipelineInstance(
       pipelineConfig,
       buildCause,
       new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY),
       md5,
       new TimeProvider());
 }
Exemplo n.º 6
0
 public Pipeline newPipelineWithFirstStageScheduled(PipelineConfig config) throws SQLException {
   Pipeline pipeline =
       instanceFactory.createPipelineInstance(
           config,
           BuildCause.createManualForced(
               modifyOneFile(
                   MaterialsMother.createMaterialsFromMaterialConfigs(config.materialConfigs()),
                   ModificationsMother.nextRevision()),
               Username.ANONYMOUS),
           new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY),
           md5,
           new TimeProvider());
   savePipelineWithStagesAndMaterials(pipeline);
   return pipeline;
 }
Exemplo n.º 7
0
 public Pipeline newPipelineWithAllStagesPassed(PipelineConfig config) throws SQLException {
   Pipeline pipeline = newPipelineWithFirstStagePassed(config);
   for (StageConfig stageConfig : config) {
     if (config.first().equals(stageConfig)) {
       continue;
     }
     Stage instance =
         instanceFactory.createStageInstance(
             stageConfig,
             new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY),
             md5,
             new TimeProvider());
     stageDao.saveWithJobs(pipeline, instance);
     passStage(instance);
   }
   return pipelineDao.loadPipeline(pipeline.getId());
 }
Exemplo n.º 8
0
 public void createJobInstances(
     JobInstances jobs,
     SchedulingContext context,
     JobConfig jobConfig,
     String stageName,
     final JobNameGenerator nameGenerator,
     final Clock clock,
     InstanceFactory instanceFactory) {
   instanceFactory.reallyCreateJobInstance(
       jobConfig,
       jobs,
       null,
       CaseInsensitiveString.str(jobConfig.name()),
       false,
       false,
       context,
       clock);
 }
Exemplo n.º 9
0
  public Pipeline rescheduleTestPipeline(String pipelineName, String stageName, String userName)
      throws SQLException {
    String[] jobConfigNames = new String[] {};
    PipelineConfig pipelineConfig = configurePipeline(pipelineName, stageName, jobConfigNames);

    BuildCause buildCause =
        BuildCause.createManualForced(
            modifyOneFile(
                MaterialsMother.createMaterialsFromMaterialConfigs(
                    pipelineConfig.materialConfigs()),
                ModificationsMother.currentRevision()),
            Username.ANONYMOUS);

    Pipeline pipeline =
        instanceFactory.createPipelineInstance(
            pipelineConfig,
            buildCause,
            new DefaultSchedulingContext(GoConstants.DEFAULT_APPROVED_BY),
            md5,
            new TimeProvider());
    return savePipelineWithStagesAndMaterials(pipeline);
  }
Exemplo n.º 10
0
 public Stage scheduleStage(Pipeline pipeline, StageConfig stageConfig, int order) {
   Stage instance =
       instanceFactory.createStageInstance(
           stageConfig, new DefaultSchedulingContext("cruise"), md5, new TimeProvider());
   return saveStage(pipeline, instance, order);
 }