Skip to content

Commit

Permalink
Improvements (#7)
Browse files Browse the repository at this point in the history
* Upgrade dependencies

* Remove unused static code analysis config files

The maven plugins have been removed in commit 73a92a2.

* Remove unused imports

* Simplify code

* Replace deprecated HudsonTestCase

* Remove unchecked type casts

* Fix stream closing

This was found by SpotBugs (OS_OPEN_STREAM).

* Mark deprecated fields transient to exclude them from XStream

Using the `transient' keyword is also described in the official guide on backward compatibility:
https://wiki.jenkins.io/display/JENKINS/Hint+on+retaining+backward+compatibility

This was found by SpotBugs (URF_UNREAD_FIELD).

* Consistent wording and punctuation
  • Loading branch information
darxriggs authored and slide committed Oct 3, 2019
1 parent 0c834af commit 4a8126a
Show file tree
Hide file tree
Showing 42 changed files with 103 additions and 300 deletions.
21 changes: 8 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.32</version>
<version>3.50</version>
</parent>

<artifactId>publish-over-ftp</artifactId>
Expand All @@ -40,8 +40,9 @@
<url>http://wiki.jenkins-ci.org/display/JENKINS/Publish+Over+FTP+Plugin</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<findbugs.failOnError>false</findbugs.failOnError>
<jenkins.version>2.60.3</jenkins.version>
<java.level>8</java.level>
</properties>

<licenses>
Expand All @@ -68,7 +69,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>publish-over</artifactId>
<version>0.21</version>
<version>0.22</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
Expand All @@ -83,7 +84,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<version>4.12</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand All @@ -95,7 +96,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.8.5</version>
<version>1.10.19</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand All @@ -107,16 +108,15 @@
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>2.4</version>
<version>2.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
<version>2.4</version>
<version>2.5.2</version>
<scope>test</scope>
</dependency>

</dependencies>

<scm>
Expand All @@ -143,11 +143,6 @@
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
<repository>
<id>releases</id>
<name>Releases</name>
<url>https://oss.sonatype.org/content/repositories/releases</url>
</repository>
</repositories>

<pluginRepositories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ public FTPClient createFTPClient() throws GeneralSecurityException, FileNotFound
String trustStorePath = System.getProperty("javax.net.ssl.trustStore");
if (trustStorePath != null) {
String trustStorePassword = System.getProperty("javax.net.ssl.trustStorePassword");
if (trustStorePassword != null) {
ts.load(new FileInputStream(trustStorePath), trustStorePassword.toCharArray());
} else {
ts.load(new FileInputStream(trustStorePath), null);
try (FileInputStream stream = new FileInputStream(trustStorePath)) {
if (trustStorePassword != null) {
ts.load(stream, trustStorePassword.toCharArray());
} else {
ts.load(stream, null);
}
}
} else {
ts.load(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public Object readResolve() {
}
}

/** left in to prevent xstream noise */
/** prevent complaints from XStream */
@Deprecated
public static class DescriptorMessages implements BPPluginDescriptor.BPDescriptorMessages { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import jenkins.plugins.publish_over_ftp.BapFtpPublisherPlugin;
import jenkins.plugins.publish_over_ftp.Messages;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

@Extension
public class BapFtpHostConfigurationDescriptor extends Descriptor<BapFtpHostConfiguration> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,17 @@
import jenkins.plugins.publish_over_ftp.options.FtpPluginDefaults;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

import java.util.List;

@SuppressWarnings("PMD.TooManyMethods")
public class BapFtpPublisherPluginDescriptor extends BuildStepDescriptor<Publisher> {

/** null - prevent complaints from xstream */
private BPPluginDescriptor.BPDescriptorMessages msg;
/** null - prevent complaints from xstream */
private Class hostConfigClass;
private final CopyOnWriteList<BapFtpHostConfiguration> hostConfigurations = new CopyOnWriteList<BapFtpHostConfiguration>();
/** prevent complaints from XStream */
@Deprecated private transient BPPluginDescriptor.BPDescriptorMessages msg;
/** prevent complaints from XStream */
@Deprecated private transient Class hostConfigClass;
private final CopyOnWriteList<BapFtpHostConfiguration> hostConfigurations = new CopyOnWriteList<>();
private FtpDefaults defaults;

public BapFtpPublisherPluginDescriptor() {
Expand Down Expand Up @@ -166,9 +165,6 @@ public static BPBuildInfo createDummyBuildInfo() {
}

public Object readResolve() {
// nuke the legacy config
msg = null;
hostConfigClass = null;
if (defaults == null)
defaults = new FtpPluginDefaults();
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import hudson.model.Descriptor;
import hudson.util.FormValidation;
import jenkins.model.Jenkins;
import jenkins.plugins.publish_over.BPTransfer;
import jenkins.plugins.publish_over.BPValidators;
import jenkins.plugins.publish_over_ftp.BapFtpPublisherPlugin;
import jenkins.plugins.publish_over_ftp.BapFtpTransfer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public abstract class FtpDefaults implements Describable<FtpDefaults>, ExtensionPoint, FtpOptions {

public static DescriptorExtensionList<FtpDefaults, FtpDefaultsDescriptor> all() {
return Jenkins.getInstance().<FtpDefaults, FtpDefaultsDescriptor>getDescriptorList(FtpDefaults.class);
return Jenkins.getInstance().getDescriptorList(FtpDefaults.class);
}

public FtpDefaultsDescriptor getDescriptor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import hudson.model.Describable;
import hudson.model.Descriptor;
import jenkins.model.Jenkins;
import jenkins.plugins.publish_over.BPTransfer;
import org.kohsuke.stapler.DataBoundConstructor;

public class FtpOverrideTransferDefaults implements FtpTransferOptions, Describable<FtpOverrideTransferDefaults> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
~ THE SOFTWARE.
-->

<div>Send files over FTP as a build step during the build</div>
<div>Send files over FTP as a build step during the build.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
-->

<div>
<p>Set a different character encoding. Leave blank for the default (ISO-8859-1)</p>
<p>Set a different character encoding. Leave blank for the default (ISO-8859-1).</p>
<p>At least one Chinese server is known to like &quot;GB2312&quot;
</p>
<p>From the commons-net javadoc:<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
-->

<div>
<p>Do not try to create nested directories with a single MKD command</p>
<p>Do not try to create nested directories with a single MKD command.</p>
<p>The default behaviour when creating directories is to try to create the target directory
including any missing directories with a single command. If this fails, the plugin
will fall back to creating each directory individually. Some FTP servers, when asked to create
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
~ THE SOFTWARE.
-->

<div>The password to login with</div>
<div>The password to log in with.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
~ THE SOFTWARE.
-->

<div>FTP hostname or IP address to connect to</div>
<div>FTP hostname or IP address to connect to.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
~ THE SOFTWARE.
-->

<div>The port the FTP server is listening on</div>
<div>The port the FTP server is listening on.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
-->

<div>
<p>Timeout in milliseconds for the FTP connection, and when reading data</p>
<p>Set to zero to disable</p>
<p>Timeout in milliseconds for the FTP connection, and when reading data.</p>
<p>Set to zero to disable.</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
~ THE SOFTWARE.
-->

<div>User trusted certificate</div>
<div>User trusted certificate.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
<div>
<p>Select to use the PORT command to tell the server to connect to the client when transferring data.</p>
<p>The default (unchecked) option uses the PASV command (passive mode) which means that the client will always connect to the server.
This is usually what you want, as it allows the FTP client to get through more firewalls</p>
This is usually what you want, as it allows the FTP client to get through more firewalls.</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
~ THE SOFTWARE.
-->

<div>Use explicit FTP over TLS</div>
<div>Use explicit FTP over TLS.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
~ THE SOFTWARE.
-->

<div>Use implicit FTP over TLS</div>
<div>Use implicit FTP over TLS.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
~ THE SOFTWARE.
-->

<div>The username to login with</div>
<div>The username to log in with.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
~ THE SOFTWARE.
-->

<div>Send build artifacts over FTP as a build step during a promotion process</div>
<div>Send build artifacts over FTP as a build step during a promotion process.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
-->

<div>
<p>Set the label for this Server instance - for use with Parameterized publishing</p>

<p>Expand the help for Parameterized publishing for more details</p>
<p>Set the label for this Server instance - for use with Parameterized publishing.</p>
<p>Expand the help for Parameterized publishing for more details.</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
-->

<div>
<p>Use the build time of the promotion when the remote directory is a date format</p>
<p>Use the build time of the promotion when the remote directory is a date format.</p>
<p>By default this plugin uses the time of the original build (the one that is being promoted) when formatting the
remote directory. Setting this option will mean that if you use the remote directory is a date format option,
it will use the time that the promotion process runs, instead of the original build.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
-->

<div>
<p>Set the root directory for the Source files to the workspace</p>
<p>Set the root directory for the Source files to the workspace.</p>
<p>By default this plugin uses the artifacts directory (where archived artifacts are stored). This allows the artifacts
from the build number that you are promoting to be sent somewhere else.</p>
<p>If you run tasks that produce files in the workspace during the promotion and you want to publish them, then set this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
-->

<div>
<p>Matrix jobs will always use the workspace as the base directory for Source files - even in promotions</p>
<p>Matrix jobs will always use the workspace as the base directory for Source files - even in promotions.</p>
<p>The promotion process will only run once and the build artifacts are stored beneath each configuration.</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
-->

<div>
<p>Set the label for this Server instance - for use with Parameterized publishing</p>

<p>Expand the help for Parameterized publishing for more details</p>
<p>Set the label for this Server instance - for use with Parameterized publishing.</p>
<p>Expand the help for Parameterized publishing for more details.</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<div>
<p>Select to publish from the Jenkins master.</p>
<p>The default is to publish from the server that holds the files to transfer (workspace on the slave, or artifacts directory on the master)<br />
<p>The default is to publish from the server that holds the files to transfer (workspace on the agent, or artifacts directory on the master)<br />
Enabling this option could help dealing with strict network configurations and firewall rules.<br />
This option will cause the files to be transferred through the master before being sent to the remote server, this may
increase network traffic, and could increase the build time.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
~ THE SOFTWARE.
-->

<div>Select to continue publishing to the other FTP servers after a problem with a previous server</div>
<div>Select to continue publishing to the other FTP servers after a problem with a previous server.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
~ THE SOFTWARE.
-->

<div>Select to mark the build as a failure if there is a problem publishing to a server. The default is to mark the build as unstable</div>
<div>Select to mark the build as a failure if there is a problem publishing to a server. The default is to mark the build as unstable.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
<p>Set the NODE_NAME for the master Jenkins.</p>
<p>Set this option to give a value to the NODE_NAME environment variable when the value is missing (the Jenkins
master).<br />
This is useful if you use the $NODE_NAME variable in the remoteDirectory
This is useful if you use the NODE_NAME variable in the remoteDirectory
option and the build may occur on the master.</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
~ THE SOFTWARE.
-->

<div>Send build artifacts over FTP</div>
<div>Send build artifacts over FTP.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
~ THE SOFTWARE.
-->

<div>The number of times to retry this server in the event of failure</div>
<div>The number of times to retry this server in the event of failure.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
~ THE SOFTWARE.
-->

<div>The time to wait, in milliseconds, before attempting another transfer</div>
<div>The time to wait, in milliseconds, before attempting another transfer.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
-->

<div>
<p>Only create files on the server, don&apos;t create directories (except for the remote directory, if present)</p>
<p>Only create files on the server, don&apos;t create directories (except for the remote directory, if present).</p>
<p><strong>All files that have been selected to transfer must have unique filenames.</strong> The publisher will stop and fail as
soon as a duplicate filename is found when using the flatten option.</p>
</div>

0 comments on commit 4a8126a

Please sign in to comment.