use of com.thoughtworks.go.config.JobNotFoundException in project gocd by gocd.
the class RestfulService method findJob.
/**
* buildId should only be given when caller is absolutely sure about the job instance
* (makes sense in agent-uploading artifacts/properties scenario because agent won't run a job if its copied over(it only executes real jobs)) -JJ
*/
public JobIdentifier findJob(String pipelineName, String counterOrLabel, String stageName, String stageCounter, String buildName, Long buildId) {
JobConfigIdentifier jobConfig = goConfigService.translateToActualCase(new JobConfigIdentifier(pipelineName, stageName, buildName));
Pipeline pipeline = pipelineService.findPipelineByCounterOrLabel(jobConfig.getPipelineName(), counterOrLabel);
stageCounter = StringUtils.isEmpty(stageCounter) ? JobIdentifier.LATEST : stageCounter;
StageIdentifier stageIdentifier = translateStageCounter(pipeline.getIdentifier(), jobConfig.getStageName(), stageCounter);
JobIdentifier jobId;
if (buildId == null) {
jobId = jobResolverService.actualJobIdentifier(new JobIdentifier(stageIdentifier, jobConfig.getJobName()));
} else {
jobId = new JobIdentifier(stageIdentifier, jobConfig.getJobName(), buildId);
}
if (jobId == null) {
//fix for #5739
throw new JobNotFoundException(pipelineName, stageName, buildName);
}
return jobId;
}
Aggregations