private boolean isUnlockable(String pipelineName, OperationResult result) {
if (!goConfigService.isLockable(pipelineName)) {
String msg = format("No lock exists within the pipeline configuration for %s", pipelineName);
result.conflict(msg, msg, HealthStateType.general(HealthStateScope.GLOBAL));
return false;
}
StageIdentifier stageIdentifier = pipelineLockService.lockedPipeline(pipelineName);
if (stageIdentifier == null) {
String msg = "Lock exists within the pipeline configuration but no pipeline instance is currently in progress";
result.conflict(msg, msg, HealthStateType.general(HealthStateScope.GLOBAL));
return false;
}
if (stageService.isAnyStageActiveForPipeline(stageIdentifier.pipelineIdentifier())) {
String message = "Locked pipeline instance is currently running (one of the stages is in progress)";
result.conflict(message, message, HealthStateType.general(HealthStateScope.GLOBAL));
return false;
}
return true;
}