/** * Populates and return pipelines for the supplied pipeline prototype with the current status. * * @param noOfPipelines number of pipeline instances */ public List<Pipeline> createPipelineLatest(int noOfPipelines, ItemGroup context) { List<Pipeline> result = new ArrayList<Pipeline>(); Iterator it = firstProject.getBuilds().iterator(); for (int i = 0; i < noOfPipelines && it.hasNext(); i++) { AbstractBuild firstBuild = (AbstractBuild) it.next(); List<Change> pipelineChanges = Change.getChanges(firstBuild); String pipeLineTimestamp = PipelineUtils.formatTimestamp(firstBuild.getTimeInMillis()); List<Stage> pipelineStages = new ArrayList<Stage>(); for (Stage stage : getStages()) { pipelineStages.add(stage.createLatestStage(context, firstBuild)); } Pipeline pipelineLatest = new Pipeline( getName(), firstProject, firstBuild.getDisplayName(), pipeLineTimestamp, Trigger.getTriggeredBy(firstBuild), UserInfo.getContributors(firstBuild), pipelineStages, false); pipelineLatest.setChanges(pipelineChanges); result.add(pipelineLatest); } return result; }