Search in sources :

Example 1 with JobNotFoundException

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;
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) JobNotFoundException(com.thoughtworks.go.config.JobNotFoundException) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) JobConfigIdentifier(com.thoughtworks.go.domain.JobConfigIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline)

Aggregations

JobNotFoundException (com.thoughtworks.go.config.JobNotFoundException)1 JobConfigIdentifier (com.thoughtworks.go.domain.JobConfigIdentifier)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 Pipeline (com.thoughtworks.go.domain.Pipeline)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1