@Test public void promote() throws Exception { }
@Override public void promote(PipelinePromoteArg pipelinePromoteArg) { log.info("try to promote image", pipelinePromoteArg); String id = pipelinePromoteArg.getPipelineInstance(); PipeLineAction action = pipelinePromoteArg.getAction(); PipelineInstance instance = getPipelineInstance(id); PipelineSchema pipelineSchema = getPipelineSchema(instance.getPipeline()); List<PipelineStageSchema> pipelineStages = pipelineSchema.getPipelineStages(); PipelineInstanceHistory lastHistory = instance.getOrCreateHistoryByStage(pipelinePromoteArg.getStage()); lastHistory.addComments(pipelinePromoteArg.getComment()); switch (action) { case PROMOTE: instance.setState(State.IN_PROGRESS); PipelineStageSchema nextStage = null; PipelineStageSchema currentStage = null; for (int i = 0; i < pipelineStages.size(); i++) { PipelineStageSchema pipelineStage = pipelineStages.get(i); if (pipelineStage.getName().equals(lastHistory.getStage())) { currentStage = pipelineStage; if (i < pipelineStages.size() - 1) { nextStage = pipelineStages.get(i + 1); } break; } } if (nextStage == null) { instance.setState(State.FINISHED); return; } PipelineInstanceHistory nextHistory = instance.getOrCreateHistoryByStage(nextStage.getName()); String tag = createTag(currentStage, nextStage, instance, pipelineSchema); nextHistory.setTag(tag); pipelineInstances.flush(instance.getId()); break; case REJECT: instance.setState(State.INTERRUPTED); deleteTag(instance, lastHistory); break; } riseEvent(pipelineSchema, action.name()); }
PipelineServiceImpl implements PipelineService { @Override public void promote(PipelinePromoteArg pipelinePromoteArg) { log.info("try to promote image", pipelinePromoteArg); String id = pipelinePromoteArg.getPipelineInstance(); PipeLineAction action = pipelinePromoteArg.getAction(); PipelineInstance instance = getPipelineInstance(id); PipelineSchema pipelineSchema = getPipelineSchema(instance.getPipeline()); List<PipelineStageSchema> pipelineStages = pipelineSchema.getPipelineStages(); PipelineInstanceHistory lastHistory = instance.getOrCreateHistoryByStage(pipelinePromoteArg.getStage()); lastHistory.addComments(pipelinePromoteArg.getComment()); switch (action) { case PROMOTE: instance.setState(State.IN_PROGRESS); PipelineStageSchema nextStage = null; PipelineStageSchema currentStage = null; for (int i = 0; i < pipelineStages.size(); i++) { PipelineStageSchema pipelineStage = pipelineStages.get(i); if (pipelineStage.getName().equals(lastHistory.getStage())) { currentStage = pipelineStage; if (i < pipelineStages.size() - 1) { nextStage = pipelineStages.get(i + 1); } break; } } if (nextStage == null) { instance.setState(State.FINISHED); return; } PipelineInstanceHistory nextHistory = instance.getOrCreateHistoryByStage(nextStage.getName()); String tag = createTag(currentStage, nextStage, instance, pipelineSchema); nextHistory.setTag(tag); pipelineInstances.flush(instance.getId()); break; case REJECT: instance.setState(State.INTERRUPTED); deleteTag(instance, lastHistory); break; } riseEvent(pipelineSchema, action.name()); } }
PipelineServiceImpl implements PipelineService { @Override public void promote(PipelinePromoteArg pipelinePromoteArg) { log.info("try to promote image", pipelinePromoteArg); String id = pipelinePromoteArg.getPipelineInstance(); PipeLineAction action = pipelinePromoteArg.getAction(); PipelineInstance instance = getPipelineInstance(id); PipelineSchema pipelineSchema = getPipelineSchema(instance.getPipeline()); List<PipelineStageSchema> pipelineStages = pipelineSchema.getPipelineStages(); PipelineInstanceHistory lastHistory = instance.getOrCreateHistoryByStage(pipelinePromoteArg.getStage()); lastHistory.addComments(pipelinePromoteArg.getComment()); switch (action) { case PROMOTE: instance.setState(State.IN_PROGRESS); PipelineStageSchema nextStage = null; PipelineStageSchema currentStage = null; for (int i = 0; i < pipelineStages.size(); i++) { PipelineStageSchema pipelineStage = pipelineStages.get(i); if (pipelineStage.getName().equals(lastHistory.getStage())) { currentStage = pipelineStage; if (i < pipelineStages.size() - 1) { nextStage = pipelineStages.get(i + 1); } break; } } if (nextStage == null) { instance.setState(State.FINISHED); return; } PipelineInstanceHistory nextHistory = instance.getOrCreateHistoryByStage(nextStage.getName()); String tag = createTag(currentStage, nextStage, instance, pipelineSchema); nextHistory.setTag(tag); pipelineInstances.flush(instance.getId()); break; case REJECT: instance.setState(State.INTERRUPTED); deleteTag(instance, lastHistory); break; } riseEvent(pipelineSchema, action.name()); } @Autowired  PipelineServiceImpl(KvMapperFactory kvmf,
                               DiscoveryStorage dockerServiceRegistry,
                               RegistryRepository registryRepository,
                               @Qualifier(PipelineEvent.BUS) MessageBus<PipelineEvent> pipelineEventBus,
                               JobsManager jobsManager,
                               @Value("${dm.pipeline.updateCronExpression:* * * * * *}") String updateCronExpression); }
PipelineServiceImpl implements PipelineService { @Override public void promote(PipelinePromoteArg pipelinePromoteArg) { log.info("try to promote image", pipelinePromoteArg); String id = pipelinePromoteArg.getPipelineInstance(); PipeLineAction action = pipelinePromoteArg.getAction(); PipelineInstance instance = getPipelineInstance(id); PipelineSchema pipelineSchema = getPipelineSchema(instance.getPipeline()); List<PipelineStageSchema> pipelineStages = pipelineSchema.getPipelineStages(); PipelineInstanceHistory lastHistory = instance.getOrCreateHistoryByStage(pipelinePromoteArg.getStage()); lastHistory.addComments(pipelinePromoteArg.getComment()); switch (action) { case PROMOTE: instance.setState(State.IN_PROGRESS); PipelineStageSchema nextStage = null; PipelineStageSchema currentStage = null; for (int i = 0; i < pipelineStages.size(); i++) { PipelineStageSchema pipelineStage = pipelineStages.get(i); if (pipelineStage.getName().equals(lastHistory.getStage())) { currentStage = pipelineStage; if (i < pipelineStages.size() - 1) { nextStage = pipelineStages.get(i + 1); } break; } } if (nextStage == null) { instance.setState(State.FINISHED); return; } PipelineInstanceHistory nextHistory = instance.getOrCreateHistoryByStage(nextStage.getName()); String tag = createTag(currentStage, nextStage, instance, pipelineSchema); nextHistory.setTag(tag); pipelineInstances.flush(instance.getId()); break; case REJECT: instance.setState(State.INTERRUPTED); deleteTag(instance, lastHistory); break; } riseEvent(pipelineSchema, action.name()); } @Autowired  PipelineServiceImpl(KvMapperFactory kvmf,
                               DiscoveryStorage dockerServiceRegistry,
                               RegistryRepository registryRepository,
                               @Qualifier(PipelineEvent.BUS) MessageBus<PipelineEvent> pipelineEventBus,
                               JobsManager jobsManager,
                               @Value("${dm.pipeline.updateCronExpression:* * * * * *}") String updateCronExpression); @PostConstruct void initialize(); @Override void getOrUpdatePipeline(PipelineSchemaArg arg); @Scheduled(fixedDelay = Long.MAX_VALUE, initialDelay = 60_000) void load(); PipelineInstance createPipelineInstance(String id,
                                                   String name,
                                                   PipelineSchema pipelineSchema,
                                                   PipelineStageSchema pipelineStageName); @Override void promote(PipelinePromoteArg pipelinePromoteArg); @Override void deploy(PipelineDeployArg pipelineDeployArg); @Override void deletePipeline(String pipelineName); @Override void deleteInstance(String pipelineName); @Override Map<String, PipelineSchema> getPipelinesMap(); @Override PipelineSchema getPipeline(String pipelineId); @Override Map<String, PipelineInstance> getInstancesMap(); @Override PipelineInstance getInstance(String pipelineInstanceId); @Override Map<String, PipelineInstance> getInstancesMapByPipeline(String pipelineId); PipelineInstance getPipelineInstance(String id); PipelineSchema getPipelineSchema(String id); }
PipelineServiceImpl implements PipelineService { @Override public void promote(PipelinePromoteArg pipelinePromoteArg) { log.info("try to promote image", pipelinePromoteArg); String id = pipelinePromoteArg.getPipelineInstance(); PipeLineAction action = pipelinePromoteArg.getAction(); PipelineInstance instance = getPipelineInstance(id); PipelineSchema pipelineSchema = getPipelineSchema(instance.getPipeline()); List<PipelineStageSchema> pipelineStages = pipelineSchema.getPipelineStages(); PipelineInstanceHistory lastHistory = instance.getOrCreateHistoryByStage(pipelinePromoteArg.getStage()); lastHistory.addComments(pipelinePromoteArg.getComment()); switch (action) { case PROMOTE: instance.setState(State.IN_PROGRESS); PipelineStageSchema nextStage = null; PipelineStageSchema currentStage = null; for (int i = 0; i < pipelineStages.size(); i++) { PipelineStageSchema pipelineStage = pipelineStages.get(i); if (pipelineStage.getName().equals(lastHistory.getStage())) { currentStage = pipelineStage; if (i < pipelineStages.size() - 1) { nextStage = pipelineStages.get(i + 1); } break; } } if (nextStage == null) { instance.setState(State.FINISHED); return; } PipelineInstanceHistory nextHistory = instance.getOrCreateHistoryByStage(nextStage.getName()); String tag = createTag(currentStage, nextStage, instance, pipelineSchema); nextHistory.setTag(tag); pipelineInstances.flush(instance.getId()); break; case REJECT: instance.setState(State.INTERRUPTED); deleteTag(instance, lastHistory); break; } riseEvent(pipelineSchema, action.name()); } @Autowired  PipelineServiceImpl(KvMapperFactory kvmf,
                               DiscoveryStorage dockerServiceRegistry,
                               RegistryRepository registryRepository,
                               @Qualifier(PipelineEvent.BUS) MessageBus<PipelineEvent> pipelineEventBus,
                               JobsManager jobsManager,
                               @Value("${dm.pipeline.updateCronExpression:* * * * * *}") String updateCronExpression); @PostConstruct void initialize(); @Override void getOrUpdatePipeline(PipelineSchemaArg arg); @Scheduled(fixedDelay = Long.MAX_VALUE, initialDelay = 60_000) void load(); PipelineInstance createPipelineInstance(String id,
                                                   String name,
                                                   PipelineSchema pipelineSchema,
                                                   PipelineStageSchema pipelineStageName); @Override void promote(PipelinePromoteArg pipelinePromoteArg); @Override void deploy(PipelineDeployArg pipelineDeployArg); @Override void deletePipeline(String pipelineName); @Override void deleteInstance(String pipelineName); @Override Map<String, PipelineSchema> getPipelinesMap(); @Override PipelineSchema getPipeline(String pipelineId); @Override Map<String, PipelineInstance> getInstancesMap(); @Override PipelineInstance getInstance(String pipelineInstanceId); @Override Map<String, PipelineInstance> getInstancesMapByPipeline(String pipelineId); PipelineInstance getPipelineInstance(String id); PipelineSchema getPipelineSchema(String id);  }