Skip to content

Commit

Permalink
[JENKINS-4949] Revisiting the UI to handle multiple deployments
Browse files Browse the repository at this point in the history
I think this provides a better UI and also simplifies the code.
  • Loading branch information
kohsuke committed Jul 3, 2014
1 parent 1fe03c8 commit 504466d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 38 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.409</version>
<version>1.532</version>
</parent>

<artifactId>deploy</artifactId>
Expand Down
28 changes: 16 additions & 12 deletions src/main/java/hudson/plugins/deploy/DeployPublisher.java
Expand Up @@ -26,17 +26,21 @@
* @author Kohsuke Kawaguchi
*/
public class DeployPublisher extends Notifier implements Serializable {
private List<ContainerAdapterWrapper> adapterWrappers;
private List<ContainerAdapter> adapters;
public final String contextPath;

public final String war;
public final boolean onFailure;


/**
* @deprecated
* Use {@link #getAdapters()}
*/
public final ContainerAdapter adapter = null;

@DataBoundConstructor
public DeployPublisher(List<ContainerAdapterWrapper> adapterWrappers, String war, String contextPath, boolean onFailure, ContainerAdapter adapter) {
this.adapterWrappers = adapterWrappers;
public DeployPublisher(List<ContainerAdapter> adapters, String war, String contextPath, boolean onFailure) {
this.adapters = adapters;
this.war = war;
this.onFailure = onFailure;
this.contextPath = contextPath;
Expand All @@ -46,8 +50,8 @@ public DeployPublisher(List<ContainerAdapterWrapper> adapterWrappers, String war
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
if (build.getResult().equals(Result.SUCCESS) || onFailure) {
for (FilePath warFile : build.getWorkspace().list(this.war)) {
for(ContainerAdapterWrapper wrapper : adapterWrappers)
if(!wrapper.adapter.redeploy(warFile,contextPath,build,launcher,listener))
for(ContainerAdapter adapter : adapters)
if(!adapter.redeploy(warFile,contextPath,build,launcher,listener))
build.setResult(Result.FAILURE);
}
}
Expand All @@ -61,10 +65,10 @@ public BuildStepMonitor getRequiredMonitorService() {

public Object readResolve() {
if(adapter != null) {
if(adapterWrappers == null) {
adapterWrappers = new ArrayList<ContainerAdapterWrapper>();
if(adapters == null) {
adapters = new ArrayList<ContainerAdapter>();
}
adapterWrappers.add(new ContainerAdapterWrapper(adapter));
adapters.add(adapter);
}
return this;
}
Expand All @@ -74,8 +78,8 @@ public Object readResolve() {
*
* @return The value of adapterWrappers
*/
public List<ContainerAdapterWrapper> getAdapterWrappers() {
return adapterWrappers;
public List<ContainerAdapter> getAdapters() {
return adapters;
}

@Extension
Expand All @@ -91,7 +95,7 @@ public String getDisplayName() {
/**
* Sort the descriptors so that the order they are displayed is more predictable
*/
public List<ContainerAdapterDescriptor> getContainerAdapters() {
public List<ContainerAdapterDescriptor> getAdaptersDescriptors() {
List<ContainerAdapterDescriptor> r = new ArrayList<ContainerAdapterDescriptor>(ContainerAdapter.all());
Collections.sort(r,new Comparator<ContainerAdapterDescriptor>() {
public int compare(ContainerAdapterDescriptor o1, ContainerAdapterDescriptor o2) {
Expand Down
Expand Up @@ -8,31 +8,7 @@
</f:entry>

<f:entry title="${%Containers}" field="adapters">
<f:repeatable var="wrapper" items="${instance.adapterWrappers}" name="adapterWrappers" miniumum="1" noAddButton="false">
<table width="100%">
<f:dropdownList name="adapter" title="${%Container}">
<j:forEach var="d" items="${descriptor.containerAdapters}" varStatus="loop">
<f:dropdownListBlock value="${d.clazz.name}" title="${d.displayName}" selected="${wrapper.adapter.descriptor==d}">
<f:nested>
<table width="100%">
<tr><td>
<input type="hidden" name="stapler-class" value="${d.clazz.name}" />
</td></tr>
<j:scope>
<j:set var="descriptor" value="${d}"/>
<j:set var="instance" value="${h.ifThenElse(wrapper.adapter.descriptor==descriptor, wrapper.adapter, null)}"/>
<st:include class="${descriptor.clazz}" page="config.jelly"/>
</j:scope>
</table>
<div align="right">
<f:repeatableDeleteButton value="${%Delete Container}"/>
</div>
</f:nested>
</f:dropdownListBlock>
</j:forEach>
</f:dropdownList>
</table>
</f:repeatable>
<f:repeatableHeteroProperty field="adapters" hasHeader="true" addCaption="${%Add Container}"/>
</f:entry>

<f:entry title="${%Deploy on failure}" field="onFailure">
Expand Down

0 comments on commit 504466d

Please sign in to comment.