public String getBuildName() { return job.getName(); }
public boolean hasJobNamed(String name) { for (JobInstance thisInstance : this) { if (name.equalsIgnoreCase(thisInstance.getName())) { return true; } } return false; }
public JobInstance getByName(String name) { for (JobInstance thisInstance : this) { if (name.equals(thisInstance.getName())) { return thisInstance; } } throw bomb("Does not contain plan with name " + name); }
public String getBuildDurationKey(String pipelineName, String stageName) { return String.format("BUILD_DURATION: %s_%s_%s_%s", pipelineName, stageName, getName(), getAgentUuid()); }
public JobIdentifier(Pipeline pipeline, Stage stage, JobInstance jobInstance) { this(pipeline.getName(), pipeline.getCounter(), pipeline.getLabel(), stage.getName(), String.valueOf(stage.getCounter()), jobInstance.getName(), jobInstance.getId()); }
@Override public void jobStatusChanged(final JobInstance job) { if (job.isRescheduled()) { goCache.remove(cacheKeyForOriginalJobIdentifier(job.getIdentifier().getStageIdentifier(), job.getName())); } } }
public JobIdentifier(StageIdentifier stageIdentifier, JobInstance job) { this(stageIdentifier.getPipelineName(), stageIdentifier.getPipelineCounter(), stageIdentifier.getPipelineLabel(), stageIdentifier.getStageName(), stageIdentifier.getStageCounter(), job.getName(), job.getId()); }
private void assertRunOnAllAgentsJobInstance(JobInstance jobInstance, String jobName) { assertThat(jobInstance.getName(), is(jobName)); assertThat(jobInstance.isRunOnAllAgents(), is(true)); assertThat(jobInstance.isRunMultipleInstance(), is(false)); assertThat(jobInstance.isRerun(), is(false)); }
private void assertReRunMultipleJobInstance(JobInstance jobInstance, String jobName) { assertThat(jobInstance.getName(), is(jobName)); assertThat(jobInstance.isRunMultipleInstance(), is(true)); assertThat(jobInstance.isRunOnAllAgents(), is(false)); assertThat(jobInstance.isRerun(), is(true)); }
@Override public void afterCommit() { final ServerHealthState error = ServerHealthState.error(message, description, HealthStateType.general(HealthStateScope.forJob(jobInstance.getPipelineName(), jobInstance.getStageName(), jobInstance.getName()))); error.setTimeout(Timeout.FIVE_MINUTES); serverHealthService.update(error); appendToConsoleLog(jobInstance, message); appendToConsoleLog(jobInstance, description); } });
private void assertSimpleJobInstance(JobInstance jobInstance, String jobName) { assertThat(jobInstance.getName(), is(jobName)); assertThat(jobInstance.isRunOnAllAgents(), is(false)); assertThat(jobInstance.isRunMultipleInstance(), is(false)); assertThat(jobInstance.isRerun(), is(false)); }
private void assertRunMultipleJobInstance(JobInstance jobInstance, String jobName) { assertThat(jobInstance.getName(), is(jobName)); assertThat(jobInstance.isRunMultipleInstance(), is(true)); assertThat(jobInstance.isRunOnAllAgents(), is(false)); assertThat(jobInstance.isRerun(), is(false)); }
private StageNotificationDTO.StageDTO createStageDTO() { ArrayList<StageNotificationDTO.JobDTO> jobs = new ArrayList<>(); for (JobInstance job : stage.getJobInstances()) { StageNotificationDTO.JobDTO jobDTO = new StageNotificationDTO.JobDTO(job.getName(), job.getScheduledDate(), job.getCompletedDate(), job.getState(), job.getResult(), job.getAgentUuid()); jobs.add(jobDTO); } return new StageNotificationDTO.StageDTO(stage.getName(), stage.getCounter(), stage.getApprovalType(), stage.getApprovedBy(), stage.getState(), stage.getResult(), stage.getCreatedTime(), stage.getLastTransitionedTime(), jobs); }
private StageNotificationDTO.StageDTO createStageDTO() { ArrayList<StageNotificationDTO.JobDTO> jobs = new ArrayList<>(); for (JobInstance job : stage.getJobInstances()) { StageNotificationDTO.JobDTO jobDTO = new StageNotificationDTO.JobDTO(job.getName(), job.getScheduledDate(), job.getAssignedDate(), job.getCompletedDate(), job.getState(), job.getResult(), job.getAgentUuid()); jobs.add(jobDTO); } return new StageNotificationDTO.StageDTO(stage.getName(), stage.getCounter(), stage.getApprovalType(), stage.getApprovedBy(), stage.getState(), stage.getResult(), stage.getCreatedTime(), stage.getLastTransitionedTime(), jobs); }
@Test public void shouldGetMostRecentPassedWhenBuilding() { JobInstances jobInstances = new JobInstances(passed("passed"), building("unit")); JobInstance mostRecent = jobInstances.mostRecentPassed(); assertThat(mostRecent.getName(), is("passed")); }
private StageNotificationDTO.StageDTO createStageDTO() { ArrayList<StageNotificationDTO.JobDTO> jobs = new ArrayList<>(); for (JobInstance job : stage.getJobInstances()) { StageNotificationDTO.JobDTO jobDTO = new StageNotificationDTO.JobDTO(job.getName(), DateUtil.dateToString(job.getScheduledDate()), DateUtil.dateToString(job.getAssignedDate()), DateUtil.dateToString(job.getCompletedDate()), job.getState(), job.getResult(), job.getAgentUuid()); jobs.add(jobDTO); } return new StageNotificationDTO.StageDTO(stage.getName(), stage.getCounter(), stage.getApprovalType(), stage.getApprovedBy(), stage.getState(), stage.getResult(), DateUtil.dateToString(stage.getCreatedTime()), DateUtil.dateToString(stage.getLastTransitionedTime()), jobs); }
private StageNotificationDTO.StageDTO createStageDTO() { ArrayList<StageNotificationDTO.JobDTO> jobs = new ArrayList<>(); for (JobInstance job : stage.getJobInstances()) { StageNotificationDTO.JobDTO jobDTO = new StageNotificationDTO.JobDTO(job.getName(), DateUtil.dateToString(job.getScheduledDate()), DateUtil.dateToString(job.getAssignedDate()), DateUtil.dateToString(job.getCompletedDate()), job.getState(), job.getResult(), job.getAgentUuid()); jobs.add(jobDTO); } return new StageNotificationDTO.StageDTO(stage.getName(), stage.getCounter(), stage.getApprovalType(), stage.getApprovedBy(), stage.getPreviousStage(), stage.getState(), stage.getResult(), DateUtil.dateToString(stage.getCreatedTime()), DateUtil.dateToString(stage.getLastTransitionedTime()), jobs); }
@Test public void shouldReturnBuildInstance() { ArtifactConfigs artifactConfigs = new ArtifactConfigs(); JobConfig jobConfig = new JobConfig(new CaseInsensitiveString("test"), null, artifactConfigs); RunOnAllAgents.CounterBasedJobNameGenerator jobNameGenerator = new RunOnAllAgents.CounterBasedJobNameGenerator(CaseInsensitiveString.str(jobConfig.name())); JobInstances jobs = instanceFactory.createJobInstance(new CaseInsensitiveString("stage_foo"), jobConfig, new DefaultSchedulingContext(), new TimeProvider(), jobNameGenerator); JobInstance jobInstance = jobs.first(); assertThat(jobConfig.name(), is(new CaseInsensitiveString(jobInstance.getName()))); assertThat(jobInstance.getState(), is(JobState.Scheduled)); assertThat(jobInstance.getScheduledDate(), is(notNullValue())); }
@Test public void shouldSchedulePipelineWithFirstStage() { StageConfig stageOneConfig = StageConfigMother.stageConfig("dev", BuildPlanMother.withBuildPlans("functional", "unit")); StageConfig stageTwoConfig = StageConfigMother.stageConfig("qa", BuildPlanMother.withBuildPlans("suiteOne", "suiteTwo")); MaterialConfigs materialConfigs = MaterialConfigsMother.defaultMaterialConfigs(); PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString("mingle"), materialConfigs, stageOneConfig, stageTwoConfig); BuildCause buildCause = BuildCause.createManualForced(modifyOneFile(pipelineConfig), Username.ANONYMOUS); Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, buildCause, new DefaultSchedulingContext("test"), "some-md5", new TimeProvider()); assertThat(pipeline.getName(), is("mingle")); assertThat(pipeline.getStages().size(), is(1)); assertThat(pipeline.getStages().get(0).getName(), is("dev")); assertThat(pipeline.getStages().get(0).getJobInstances().get(0).getName(), is("functional")); }
public static StageInstanceModel toStageInstanceModel(Stage stage) { StageInstanceModel stageInstanceModel = new StageInstanceModel(stage.getName(), String.valueOf(stage.getCounter()), stage.getResult(), stage.getIdentifier()); stageInstanceModel.setApprovalType(stage.getApprovalType()); stageInstanceModel.setApprovedBy(stage.getApprovedBy()); stageInstanceModel.setRerunOfCounter(stage.getRerunOfCounter()); JobHistory jobHistory = new JobHistory(); for (JobInstance jobInstance : stage.getJobInstances()) { jobHistory.addJob(jobInstance.getName(), jobInstance.getState(), jobInstance.getResult(), jobInstance.getScheduledDate()); } stageInstanceModel.setBuildHistory(jobHistory); return stageInstanceModel; }