public StageInstanceModel getLatestStage() { PipelineInstanceModel latestPipelineInstance = pipelineModel.getLatestPipelineInstance(); if (latestPipelineInstance == null) { return null; } return latestPipelineInstance.latestStage(); }
/** * Note: this check should be part of the scheduling checker. * We will refactor it down to that point. */ public boolean canForce() { return canForce && !getLatestPipelineInstance().isPreparingToSchedule(); }
/** * * @deprecated use add method. This is a test helper */ public void addStage(String name, JobHistory history) { add(new StageInstanceModel(name, "1", history)); }
public static PipelineInstanceModel custom(String... stageNames) { PipelineInstanceModel pipelineInstanceModel = PipelineInstanceModel.createEmptyModel(); pipelineInstanceModel.setStageHistory(new StageInstanceModels()); for (String stageName : stageNames) { StageInstanceModel stageHistoryItem = new StageInstanceModel(); stageHistoryItem.setName(stageName); pipelineInstanceModel.getStageHistory().add(stageHistoryItem); } return pipelineInstanceModel; }
public void add(PipelineModel pipelineModel) { PipelineModel model = getExistingPipelineModelOrCacheThisOneAndGetItBack(new PipelineModel(pipelineModel, false)); for (PipelineInstanceModel pipelineInstanceModel : pipelineModel.getActivePipelineInstances()) { model.addPipelineInstance(pipelineInstanceModel); } }
public String getApprovedBy() { return getStageHistory().first().getApprovedBy(); }
public static PipelineInstanceModel custom(StageInstanceModel... stages) { PipelineInstanceModel pipelineInstanceModel = PipelineInstanceModel.createEmptyModel(); pipelineInstanceModel.setStageHistory(new StageInstanceModels()); for (StageInstanceModel stage : stages) { pipelineInstanceModel.getStageHistory().add(stage); } return pipelineInstanceModel; } }
@Before public void setUp() throws Exception { stageHistory = new StageInstanceModels(); stageHistory.add(new StageInstanceModel(STAGE_UT, "1", new JobHistory())); stageHistory.add(new StageInstanceModel(STAGE_FT, "1", new JobHistory())); stageHistory.add(new StageInstanceModel(STAGE_RELEASE, "1", new JobHistory())); }
private PipelineModel addInstanceTo(PipelineModel pipelineModel) { pipelineModel.addPipelineInstance(new PipelineInstanceModel(pipelineModel.getName(), 1, "label", BuildCause.createManualForced(), new StageInstanceModels())); return pipelineModel; } }
public boolean hasPreviousStageBeenScheduled(String stageName) { StageInstanceModel stage = stageHistory.byName(stageName); int index = stageHistory.indexOf(stage); if (index == 0) { return true; } if (index > 0) { return stageHistory.get(index - 1).isScheduled(); } return false; }
private PipelineInstanceModel pipelineNamed(String name) { StageInstanceModels stages = new StageInstanceModels(); stages.add(new StageInstanceModel("dev", "10", JobHistory.withJob("dev", JobState.Completed, JobResult.Failed, new Date()))); return PipelineInstanceModel.createPipeline(name, -1, "1.0", BuildCause.createWithEmptyModifications(), stages); }
public boolean hasNeverCheckedForRevisions() { return getLatestPipelineInstance().hasNeverCheckedForRevisions(); }
public StageInstanceModel stage(String stageName) { return getStageHistory().byName(stageName); }
public void selectStage(String selectedStageName) { StageInstanceModel stage = stageHistory.byName(selectedStageName); if (stage != null && stage.isScheduled()) { stage.setSelected(true); } }
public StageInstanceModels addFutureStage(String name, boolean isAutoApproved) { add(new NullStageHistoryItem(name, isAutoApproved)); return this; }
public JobHistory addJob(String name, JobState state, JobResult result, Date scheduledDate) { add(new JobHistoryItem(name, state, result, scheduledDate)); return this; }
public PipelineModel pipelineModelForPipelineName(String pipelineName, boolean canForce, boolean canOperate, PipelinePauseInfo pipelinePauseInfo) { return getExistingPipelineModelOrCacheThisOneAndGetItBack(new PipelineModel(pipelineName, canForce, canOperate, pipelinePauseInfo)); }
public Date getScheduledDate() { // All builds in a stage are scheduled at the same time, so this is safe. return this.first().getScheduledDate(); }
public Boolean isLatestStageSuccessful() { return latestStage().hasPassed(); }