Skip to content

Commit

Permalink
[FIXED JENKINS-10094] Retry uploads on bad connections
Browse files Browse the repository at this point in the history
Moved "Verbose output in console" to new advanced section
Swtiched some of the checkboxes from entry/@title to checkbox/@title to prevent longer descriptions from reformatting the view too much
  • Loading branch information
bap2000 committed Jul 7, 2011
1 parent e707230 commit 8ad07cb
Show file tree
Hide file tree
Showing 15 changed files with 271 additions and 33 deletions.
Expand Up @@ -46,8 +46,12 @@ public class BapFtpPublisher extends BapPublisher<BapFtpTransfer> implements Des

@DataBoundConstructor
public BapFtpPublisher(final String configName, final boolean verbose, final ArrayList<BapFtpTransfer> transfers,
final boolean useWorkspaceInPromotion, final boolean usePromotionTimestamp) {
super(configName, verbose, transfers, useWorkspaceInPromotion, usePromotionTimestamp);
final boolean useWorkspaceInPromotion, final boolean usePromotionTimestamp, final BapFtpRetry retry) {
super(configName, verbose, transfers, useWorkspaceInPromotion, usePromotionTimestamp, retry);
}

public BapFtpRetry getRetry() {
return (BapFtpRetry) super.getRetry();
}

public BapFtpPublisherDescriptor getDescriptor() {
Expand Down
92 changes: 92 additions & 0 deletions src/main/java/jenkins/plugins/publish_over_ftp/BapFtpRetry.java
@@ -0,0 +1,92 @@
/*
* The MIT License
*
* Copyright (C) 2010-2011 by Anthony Robinson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package jenkins.plugins.publish_over_ftp;

import hudson.Extension;
import hudson.model.Describable;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.util.FormValidation;
import jenkins.plugins.publish_over.Retry;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;

public class BapFtpRetry extends Retry implements Describable<BapFtpRetry> {

@DataBoundConstructor
public BapFtpRetry(final int retries, final long retryDelay) {
super(retries, retryDelay);
}

public BapFtpRetryDescriptor getDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapFtpRetryDescriptor.class);
}

public boolean equals(final Object that) {
if (this == that) return true;
if (that == null || getClass() != that.getClass()) return false;

return addToEquals(new EqualsBuilder(), (BapFtpRetry) that).isEquals();
}

public int hashCode() {
return addToHashCode(new HashCodeBuilder()).toHashCode();
}

public String toString() {
return addToToString(new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)).toString();
}

@Extension
public static class BapFtpRetryDescriptor extends Descriptor<BapFtpRetry> {

@Override
public String getDisplayName() {
return Messages.retry_descriptor_displayName();
}

public int getDefaultRetries() {
return Retry.DEFAULT_RETRIES;
}

public long getDefaultRetryDelay() {
return Retry.DEFAULT_RETRY_DELAY;
}

public FormValidation doCheckRetries(@QueryParameter final String value) {
return FormValidation.validateNonNegativeInteger(value);
}

public FormValidation doCheckRetryDelay(@QueryParameter final String value) {
return FormValidation.validatePositiveInteger(value);
}

}

}
Expand Up @@ -24,7 +24,7 @@
~ THE SOFTWARE.
-->

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:poj="/pojelly">
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form" xmlns:poj="/pojelly">

<f:entry title="${%hostconfig.title}" field="configName">
<select class="setting-input" name="configName">
Expand All @@ -34,32 +34,30 @@
</select>
</f:entry>

<f:entry title="${%verbose.title}" field="verbose">
<f:checkbox />
</f:entry>

<j:if test="${inPromotion}">
<j:choose>
<j:when test="${it.getClass().canonicalName == 'hudson.matrix.MatrixProject'}">
<j:set var="matrixPromotion" value="true"/>
<f:entry title="${%useWorkspaceInPromotion.title}" help="${descriptor.getHelpFile('useWorkspaceInPromotionForMatrix')}">
<input type="checkbox" checked="true" disabled="true"/>
</f:entry>
<f:invisibleEntry>
<f:checkbox name="useWorkspaceInPromotion" checked="true"/>
</f:invisibleEntry>
<poj:disabled-checkbox field="useWorkspaceInPromotion" title="${%useWorkspaceInPromotion.title}" checked="true" helpField="useWorkspaceInPromotionForMatrix"/>
</j:when>
<j:otherwise>
<f:entry title="${%useWorkspaceInPromotion.title}" field="useWorkspaceInPromotion">
<f:checkbox/>
<f:entry field="useWorkspaceInPromotion">
<poj:checkbox title="${%useWorkspaceInPromotion.title}"/>
</f:entry>
</j:otherwise>
</j:choose>
<f:entry title="${%usePromotionTimestamp.title}" field="usePromotionTimestamp">
<f:checkbox/>
<f:entry field="usePromotionTimestamp">
<poj:checkbox title="${%usePromotionTimestamp.title}"/>
</f:entry>
</j:if>

<f:advanced>
<f:entry field="verbose">
<poj:checkbox title="${%verbose.title}"/>
</f:entry>
<f:optionalProperty title="${%retry.title}" field="retry"/>
</f:advanced>

<f:entry title="${%transfers.section}">
<j:scope>
<j:set var="descriptor" value="${descriptor.transferDescriptor}"/>
Expand Down
Expand Up @@ -23,10 +23,11 @@
#

hostconfig.title=Name
verbose.title=Verbose output<br />in console
useWorkspaceInPromotion.title=Use the<br />workspace
usePromotionTimestamp.title=Use promotion<br />timestamp
verbose.title=Verbose output in console
useWorkspaceInPromotion.title=Use the workspace
usePromotionTimestamp.title=Use promotion timestamp
transfers.section=Transfers
transfers.dragAndDropLabel=Transfer Set
addTransfer.value=Add Transfer Set
deleteTransfer.value=Delete Transfer Set
retry.title=Retry
@@ -0,0 +1,29 @@
<!--
~ The MIT License
~
~ Copyright (C) 2010-2011 by Anthony Robinson
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in
~ all copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
~ THE SOFTWARE.
-->

<div>
<p>If publishing to this server fails, try again.</p>
<p>Files that were successfully transferred will not be re-sent.<br>
If the <em>Clean remote</em> option is selected, and succeeds, it will not be attempted again.</p>
</div>
Expand Up @@ -24,7 +24,7 @@
~ THE SOFTWARE.
-->

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form" xmlns:poj="/pojelly">

<j:set var="instance" value="${instance.delegate}"/>

Expand All @@ -44,14 +44,14 @@
</j:scope>

<f:advanced>
<f:entry title="${%continueOnError.title}" field="continueOnError">
<f:checkbox/>
<f:entry field="continueOnError">
<poj:checkbox title="${%continueOnError.title}"/>
</f:entry>
<f:entry title="${%failOnError.title}" field="failOnError">
<f:checkbox/>
<f:entry field="failOnError">
<poj:checkbox title="${%failOnError.title}"/>
</f:entry>
<f:entry title="${%alwaysPublishFromMaster.title}" field="alwaysPublishFromMaster">
<f:checkbox/>
<f:entry field="alwaysPublishFromMaster">
<poj:checkbox title="${%alwaysPublishFromMaster.title}"/>
</f:entry>
<j:if test="${descriptor.canSetMasterNodeName()}">
<f:entry title="${%masterNodeName.title}" field="masterNodeName">
Expand Down
Expand Up @@ -29,4 +29,4 @@ deletePublisher.value=Delete Server
continueOnError.title=Publish to other FTP servers if an error occurs
failOnError.title=Fail the build if an error occurs
alwaysPublishFromMaster.title=Always FTP from master
masterNodeName.title=Give the master a NODE_NAME
masterNodeName.title=Give the master<br>a NODE_NAME
@@ -0,0 +1,36 @@
<?jelly escape-by-default='true'?>

<!--
~ The MIT License
~
~ Copyright (C) 2010-2011 by Anthony Robinson
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in
~ all copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
~ THE SOFTWARE.
-->

<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">

<f:entry title="${%retries.title}" field="retries">
<f:textbox default="${descriptor.defaultRetries}"/>
</f:entry>
<f:entry title="${%retryDelay.title}" field="retryDelay">
<f:textbox default="${descriptor.defaultRetryDelay}"/>
</f:entry>

</j:jelly>
@@ -0,0 +1,26 @@
#
# The MIT License
#
# Copyright (C) 2010-2011 by Anthony Robinson
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

retries.title=Retries
retryDelay.title=Delay
@@ -0,0 +1,25 @@
<!--
~ The MIT License
~
~ Copyright (C) 2010-2011 by Anthony Robinson
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in
~ all copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
~ THE SOFTWARE.
-->

<div>The number of times to retry this server in the event of failure</div>
@@ -0,0 +1,25 @@
<!--
~ The MIT License
~
~ Copyright (C) 2010-2011 by Anthony Robinson
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in
~ all copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
~ THE SOFTWARE.
-->

<div>The time to wait, in milliseconds, before attempting another transfer</div>
Expand Up @@ -28,6 +28,7 @@ descriptor.testConnection.ok=Success
descriptor.testConnection.error=Failed to connect or change directory
transfer.descriptor.displayName=FTP Transfer
publisher.descriptor.displayName=FTP Publisher
retry.descriptor.displayName=SSH Retry
hostconfig.descriptor=FTP Host Configuration

console.message.prefix=FTP:
Expand Down
Expand Up @@ -28,6 +28,7 @@
import jenkins.plugins.publish_over_ftp.BapFtpHostConfiguration;
import jenkins.plugins.publish_over_ftp.BapFtpPublisher;
import jenkins.plugins.publish_over_ftp.BapFtpPublisherPlugin;
import jenkins.plugins.publish_over_ftp.BapFtpRetry;
import jenkins.plugins.publish_over_ftp.BapFtpTransfer;
import org.junit.Test;
import org.jvnet.hudson.test.HudsonTestCase;
Expand Down Expand Up @@ -80,8 +81,8 @@ private BapFtpPublisherPlugin createPlugin(final String config1, final String co
transfers1.add(transfer2);
final ArrayList<BapFtpTransfer> transfers2 = new ArrayList<BapFtpTransfer>();
transfers2.add(transfer3);
final BapFtpPublisher publisher1 = new BapFtpPublisher(config1, true, transfers1, false, false);
final BapFtpPublisher publisher2 = new BapFtpPublisher(config2, false, transfers2, false, false);
final BapFtpPublisher publisher1 = new BapFtpPublisher(config1, true, transfers1, false, false, null);
final BapFtpPublisher publisher2 = new BapFtpPublisher(config2, false, transfers2, false, false, new BapFtpRetry(5, 100L));
final ArrayList<BapFtpPublisher> publishers = new ArrayList<BapFtpPublisher>();
publishers.add(publisher1);
publishers.add(publisher2);
Expand Down
Expand Up @@ -74,7 +74,7 @@ public FTPClient createFTPClient() {
final String dirToIgnore = "target";
final BapFtpTransfer transfer = new BapFtpTransfer("**/*", null, "sub-home", dirToIgnore, true, false, false, false);
final ArrayList transfers = new ArrayList(Collections.singletonList(transfer));
final BapFtpPublisher publisher = new BapFtpPublisher(testHostConfig.getName(), false, transfers, false, false);
final BapFtpPublisher publisher = new BapFtpPublisher(testHostConfig.getName(), false, transfers, false, false, null);
final ArrayList publishers = new ArrayList(Collections.singletonList(publisher));
final BapFtpPublisherPlugin plugin = new BapFtpPublisherPlugin(publishers, false, false, false, "master");

Expand Down

0 comments on commit 8ad07cb

Please sign in to comment.