Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defect #1847115: return unavailable status in case didn't find job #276

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
import com.hp.octane.integrations.dto.scm.Branch;
import com.hp.octane.integrations.dto.securityscans.FodServerConfiguration;
import com.hp.octane.integrations.dto.securityscans.SSCProjectConfiguration;
import com.hp.octane.integrations.dto.snapshots.CIBuildResult;
import com.hp.octane.integrations.dto.snapshots.CIBuildStatus;
import com.hp.octane.integrations.exceptions.ConfigurationException;
import com.hp.octane.integrations.exceptions.PermissionException;
import com.hp.octane.integrations.services.configurationparameters.FortifySSCTokenParameter;
Expand Down Expand Up @@ -349,8 +351,12 @@ public CIBuildStatusInfo getJobBuildStatus(String jobCiId, String parameterName,
if (!hasRead) {
throw new PermissionException("Missing READ permission to job " + jobCiId, HttpStatus.SC_FORBIDDEN);
}
AbstractProjectProcessor jobProcessor = JobProcessorFactory.getFlowProcessor(job);
return jobProcessor.getBuildStatus(parameterName, parameterValue);
if(job == null) {
return getUnavailableJobStatus(jobCiId, parameterName, parameterValue);
} else {
AbstractProjectProcessor jobProcessor = JobProcessorFactory.getFlowProcessor(job);
return jobProcessor.getBuildStatus(parameterName, parameterValue);
}
} finally {
stopImpersonation(securityContext);
}
Expand Down Expand Up @@ -665,6 +671,15 @@ private PipelineNode createPipelineNodeFromJobName(String name) {
.setName(name);
}

private CIBuildStatusInfo getUnavailableJobStatus(String ciJobId, String paramName, String paramValue) {
return DTOFactory.getInstance().newDTO(CIBuildStatusInfo.class)
.setBuildStatus(CIBuildStatus.UNAVAILABLE)
.setJobCiId(ciJobId)
.setParamName(paramName)
.setParamValue(paramValue)
.setResult(CIBuildResult.UNAVAILABLE);
}

private void addParametersAndDefaultBranchFromConfig(Item item, PipelineNode result) {
String defaultBranchesConfig = config != null ? config.getDefaultBranches() : null;
if(defaultBranchesConfig !=null && !defaultBranchesConfig.isEmpty()) {
Expand Down