
org.zeroturnaround.jenkins.DeployOrUpdate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liverebel-deploy Show documentation
Show all versions of liverebel-deploy Show documentation
LiveRebel Plugin helps to run updates to your JEE containers faster. LiveRebel is a tool for hot updates without downtime,
lost sessions and OutOfMemoryErrors. You have to have a running LiveRebel Command Center to use this plugin.
The newest version!
package org.zeroturnaround.jenkins;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.servlet.ServletException;
import org.kohsuke.stapler.DataBoundConstructor;
import org.zeroturnaround.jenkins.util.ArtifactAndMetadataDescriptor;
import org.zeroturnaround.liverebel.plugins.ServersUtil;
import com.zeroturnaround.liverebel.api.Forbidden;
import hudson.Extension;
import hudson.model.Hudson;
import hudson.util.FormValidation;
import static org.zeroturnaround.jenkins.util.ServerConvertUtil.serverCheckBoxToServer;
import static org.zeroturnaround.jenkins.util.ServerConvertUtil.serverToServerCheckBox;
import static org.apache.commons.lang.StringUtils.trimToNull;
public class DeployOrUpdate extends LiveRebelDeployBuilder.ActionWrapper {
public final String contextPath;
public final String artifact;
public final String app;
public final String ver;
public final String trace;
private String contextPathWithEnvVarReplaced;
public final UpdateStrategiesImpl updateStrategies;
public final List servers;
public final boolean isOverride;
@DataBoundConstructor
public DeployOrUpdate(String contextPath, String artifact, String trace, UpdateStrategiesImpl updateStrategies, List servers, OverrideForm overrideForm) {
this.artifact = trimToNull(artifact);
this.trace = trimToNull(trace);
this.contextPath = trimToNull(contextPath);
this.updateStrategies = updateStrategies;
this.servers = servers == null ? new ArrayList() : servers;
if (overrideForm != null) {
this.app = trimToNull(overrideForm.getApp());
this.ver = trimToNull(overrideForm.getVer());
this.isOverride = true;
} else {
this.app = null;
this.ver = null;
this.isOverride = false;
}
}
public String getContextPath() {
return contextPath;
}
public String getContextPathWithEnv() {
if (contextPathWithEnvVarReplaced == null) {
return contextPath;
}
else {
return contextPathWithEnvVarReplaced;
}
}
public void setContextPathWithEnvVarReplaced(String contextPathWithEnvVarReplaced) {
this.contextPathWithEnvVarReplaced = contextPathWithEnvVarReplaced;
}
@Override
public String toString() {
return "{ contextPath=" + contextPath + "; updateStrategies=" + updateStrategies + "; servers=" + servers + " }";
}
public List getServers() {
return serverToServerCheckBox(new ServersUtil(LiveRebelDeployBuilder.DescriptorImpl.newCommandCenter(), serverCheckBoxToServer(servers == null ? new ArrayList() : servers)).getServers());
}
public DescriptorImpl getDescriptor() {
return (DescriptorImpl) Hudson.getInstance().getDescriptor(getClass());
}
@Extension
public static class DescriptorImpl extends ArtifactAndMetadataDescriptor {
@Override
public String getDisplayName() {
return "Deploy or update";
}
public List getDefaultServers() {
return serverToServerCheckBox(new ServersUtil(LiveRebelDeployBuilder.DescriptorImpl.newCommandCenter(), null).getDefaultServers());
}
public String getUniqueId() {
return UUID.randomUUID().toString();
}
public FormValidation doCheckTestServers() throws IOException, ServletException {
try {
List availableServers = getDefaultServers();
if (availableServers.isEmpty()) return FormValidation.error("No connected servers!");
boolean anyOnline = false;
for (ServerCheckbox serverCheckbox : availableServers) {
if (serverCheckbox.isConnected()) anyOnline = true;
}
if (!anyOnline) return FormValidation.warning("No online servers!");
} catch (Forbidden e) {
if (e.getMessage().contains("MANAGE_GROUPS")) {
return FormValidation.error("User whose authentication token is used must have MANAGE_GROUPS permission!");
} else throw e;
}
return FormValidation.ok();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy