public long getBuildInstanceId() { return instance.getId(); }
private void savePipelineCounter(JobInstance job) { propertyDao.save(job.getId(), new Property(CRUISE_PIPELINE_COUNTER, String.valueOf(job.getIdentifier().getPipelineCounter()))); }
public boolean isSame(long buildInstanceId) { return instance.getId() == buildInstanceId; }
private void savePipelineLabel(JobInstance job) { propertyDao.save(job.getId(), new Property(CRUISE_PIPELINE_LABEL, job.getIdentifier().getPipelineLabel())); }
public Stage getStageByBuild(JobInstance jobInstance) { return getStageByBuild(jobInstance.getId()); }
private void logIfJobIsCompleted(JobInstance jobInstance) { JobState currentState = getCurrentState(jobInstance.getId()); if (currentState.isCompleted() && !jobInstance.isCopy()) { String message = String.format( "State change for a completed Job is not allowed. Job %s is currently State=%s, Result=%s", jobInstance.getIdentifier(), jobInstance.getState(), jobInstance.getResult()); LOG.warn(message, new Exception().fillInStackTrace()); } }
private DurationBean getDuration(String pipelineName, String stageName, JobInstance job) { if (job.isCompleted()) { // Calculating duration is an expensive query; only do so when the stage is building. return new DurationBean(job.getId(), 0L); } Long duration = stageDao.getDurationOfLastSuccessfulOnAgent(pipelineName, stageName, job); return new DurationBean(job.getId(), duration == null ? 0L : duration); }
private JobDetailPresentationModel presenter(JobInstance current) { String pipelineName = current.getIdentifier().getPipelineName(); String stageName = current.getIdentifier().getStageName(); JobInstances recent25 = jobInstanceService.latestCompletedJobs(pipelineName, stageName, current.getName()); AgentConfig agentConfig = goConfigService.agentByUuid(current.getAgentUuid()); Pipeline pipelineWithOneBuild = pipelineService.wrapBuildDetails(current); Tabs customizedTabs = goConfigService.getCustomizedTabs(pipelineWithOneBuild.getName(), pipelineWithOneBuild.getFirstStage().getName(), current.getName()); TrackingTool trackingTool = goConfigService.pipelineConfigNamed( new CaseInsensitiveString(pipelineWithOneBuild.getName())).trackingTool(); Properties properties = propertiesService.getPropertiesForJob(current.getId()); Stage stage = stageService.getStageByBuild(current); return new JobDetailPresentationModel(current, recent25, agentConfig, pipelineWithOneBuild, customizedTabs, trackingTool, artifactService, properties, stage); }
private void removeCachedJobInstance(JobInstance jobInstance) { String cacheKeyOfJob = cacheKeyForJobInstanceWithTransitions(jobInstance.getId()); synchronized (cacheKeyOfJob) { goCache.remove(cacheKeyOfJob); } }
private void removeCachedJobPlan(JobInstance jobInstance) { goCache.remove(cacheKeyForJobPlan(jobInstance.getId())); }
/** * @deprecated this is evil and should be removed */ public Pipeline wrapBuildDetails(JobInstance job) { Stage stageForBuild = stageService.getStageByBuild(job.getId()); stageForBuild.setJobInstances(new JobInstances(job)); Pipeline pipeline = pipelineDao.pipelineWithMaterialsAndModsByBuildId(job.getId()); pipeline.setStages(new Stages(stageForBuild)); return pipeline; }
void resetForCopy() { if (!isCopy()) { setOriginalJobId(getId()); } setId(-1); rerun = false; stateTransitions.resetTransitionIds(); }
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()); }
public void ignore(JobInstance job) { transactionTemplate.execute((TransactionCallback) status -> { latestCompletedCache.flushOnCommit(); getSqlMapClientTemplate().update("ignoreBuildById", job.getId()); return null; }); deleteJobPlanAssociatedEntities(job); }
private void saveTransition(JobInstance jobInstance, JobStateTransition transition) { transition.setJobId(jobInstance.getId()); transition.setStageId(jobInstance.getStageId()); getSqlMapClientTemplate().insert("insertTransition", transition); }
public JobIdentifier(StageIdentifier stageIdentifier, JobInstance job) { this(stageIdentifier.getPipelineName(), stageIdentifier.getPipelineCounter(), stageIdentifier.getPipelineLabel(), stageIdentifier.getStageName(), stageIdentifier.getStageCounter(), job.getName(), job.getId()); }
private void saveBuildTransition(JobInstance instance) { for (JobStateTransition transition : instance.getTransitions()) { propertyDao.save(instance.getId(), new Property(getTransitionKey(transition.getCurrentState()), formatISO8601(transition.getStateChangeTime()))); } }
private JobStateTransition assertNewJob(JobInstance newRails) { assertThat(newRails.getId(), is(-1l)); assertThat(newRails.getTransitions().size(), is(1)); JobStateTransition newSchedulingTransition = newRails.getTransitions().byState(JobState.Scheduled); assertThat(newSchedulingTransition.getId(), is(-1l)); assertThat(newRails.getResult(), is(Unknown)); assertThat(newRails.getState(), is(Scheduled)); assertThat(newRails.isRerun(), is(true)); return newSchedulingTransition; }
private void assertCopiedJob(JobInstance newJava, final long originalId) { assertThat(newJava.getId(), is(-1l)); assertThat(newJava.getTransitions().isEmpty(), is(false)); assertThat(newJava.getResult(), is(Passed)); assertThat(newJava.getState(), is(Completed)); assertThat(newJava.getTransitions().byState(Scheduled).getId(), is(-1l)); assertThat(newJava.getTransitions().byState(Completed).getId(), is(-1l)); assertThat(newJava.getOriginalJobId(), is(originalId)); assertThat(newJava.isRerun(), is(false)); assertThat(newJava.isCopy(), is(true)); }
private void deleteJobPlanAssociatedEntities(JobInstance job) { JobPlan jobPlan = loadPlan(job.getId()); environmentVariableDao.deleteAll(jobPlan.getVariables()); artifactPlanRepository.deleteAll(jobPlan.getArtifactPlansOfType(ArtifactPlanType.file)); artifactPropertiesGeneratorRepository.deleteAll(jobPlan.getPropertyGenerators()); resourceRepository.deleteAll(jobPlan.getResources()); if (jobPlan.requiresElasticAgent()) { jobAgentMetadataDao.delete(jobAgentMetadataDao.load(jobPlan.getJobId())); } }