private void configureLockCleaner( DeploymentExecutionContext context, ConfigurationItem... cisToBeLocked) { LockCleaner lockCleaner = (LockCleaner) context.getAttribute(CI_LOCK_CLEANER); if (lockCleaner == null) { lockCleaner = new LockCleaner(cisToBeLocked); context.setAttribute(CI_LOCK_CLEANER, lockCleaner); } }
@Override public Result execute(DeploymentExecutionContext context) throws Exception { Result executionResult = Result.Success; configureLockCleaner(context, cisToBeLocked); for (ConfigurationItem each : cisToBeLocked) { String targetType = (each instanceof Environment) ? "Environment " : "Container "; if (LockFileHelper.isLocked(each)) { context.logError( targetType + each.getName() + " is locked. A different deployment may already be in progress."); executionResult = Result.Fail; } context.logOutput( targetType + each.getName() + " is available, locking it for this deployment."); LockFileHelper.lock(each); } return executionResult; }