@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; }
public ConfigurationItem toConfigurationItem( DeployitDescriptorRegistry registry, FilePath workspace, EnvVars envVars, JenkinsDeploymentListener listener) { Preconditions.checkArgument(!Strings.isNullOrEmpty(getName()), "Name is required."); ConfigurationItem deployable = registry.newInstance(type, envVars.expand(getName())); if (!isNullOrEmpty(tags)) { String resolvedTags = envVars.expand(tags); deployable.setProperty("tags", newHashSet(commaSeparatedListToList(resolvedTags))); } if (properties != null) { for (NameValuePair pair : properties) { String value = stripEnclosingQuotes(nullToEmpty(pair.propertyValue)); value = envVars.expand(value); registry.setProperty(deployable, pair.propertyName, value); } } return deployable; }