Skip to content
Permalink
Browse files

[JENKINS-48920] - Make the plugin compatible with JEP-200 (#18)

* [JENKINS-48920] - Update plugin to bundle “Publish Over” 0.21 with fixes for JEP-200

* [JENKINS-48920] - Make the plugin compatible with the breaking changes in Publish over SSH

* Cleanup Hudson.getInstance() usages in the code

* Also start using JSch from a plugin

* Update Wiki link to the plugin page

* Add Jenkinsfile
  • Loading branch information
oleg-nenashev authored and slide committed Jan 13, 2018
1 parent 54271ca commit 7f952732e298ae4935e28fb6a38d290edc6af41f
Showing with 75 additions and 93 deletions.
  1. +2 −0 Jenkinsfile
  2. +1 −1 README.md
  3. +9 −38 pom.xml
  4. +2 −1 src/main/java/jenkins/plugins/publish_over_ssh/BapSshAlwaysRunPublisherPlugin.java
  5. +2 −1 src/main/java/jenkins/plugins/publish_over_ssh/BapSshBuilderPlugin.java
  6. +2 −1 src/main/java/jenkins/plugins/publish_over_ssh/BapSshCommonConfiguration.java
  7. +2 −1 src/main/java/jenkins/plugins/publish_over_ssh/BapSshCredentials.java
  8. +2 −1 src/main/java/jenkins/plugins/publish_over_ssh/BapSshHostConfiguration.java
  9. +2 −2 src/main/java/jenkins/plugins/publish_over_ssh/BapSshParamPublish.java
  10. +2 −2 src/main/java/jenkins/plugins/publish_over_ssh/BapSshPostBuildWrapper.java
  11. +2 −2 src/main/java/jenkins/plugins/publish_over_ssh/BapSshPreBuildWrapper.java
  12. +2 −2 src/main/java/jenkins/plugins/publish_over_ssh/BapSshPromotionPublisherPlugin.java
  13. +2 −1 src/main/java/jenkins/plugins/publish_over_ssh/BapSshPublisher.java
  14. +2 −2 src/main/java/jenkins/plugins/publish_over_ssh/BapSshPublisherLabel.java
  15. +3 −1 src/main/java/jenkins/plugins/publish_over_ssh/BapSshPublisherPlugin.java
  16. +2 −2 src/main/java/jenkins/plugins/publish_over_ssh/BapSshRetry.java
  17. +2 −2 src/main/java/jenkins/plugins/publish_over_ssh/BapSshTransfer.java
  18. +1 −2 src/main/java/jenkins/plugins/publish_over_ssh/descriptor/BapSshCredentialsDescriptor.java
  19. +2 −2 src/main/java/jenkins/plugins/publish_over_ssh/descriptor/BapSshHostConfigurationDescriptor.java
  20. +3 −3 src/main/java/jenkins/plugins/publish_over_ssh/descriptor/BapSshPublisherDescriptor.java
  21. +5 −5 src/main/java/jenkins/plugins/publish_over_ssh/descriptor/BapSshPublisherPluginDescriptor.java
  22. +2 −2 src/main/java/jenkins/plugins/publish_over_ssh/descriptor/BapSshTransferDescriptor.java
  23. +3 −2 src/main/java/jenkins/plugins/publish_over_ssh/options/SshDefaults.java
  24. +2 −2 src/main/java/jenkins/plugins/publish_over_ssh/options/SshOverrideInstanceConfigDefaults.java
  25. +2 −2 src/main/java/jenkins/plugins/publish_over_ssh/options/SshOverrideParamPublishDefaults.java
  26. +3 −3 src/main/java/jenkins/plugins/publish_over_ssh/options/SshOverridePublisherDefaults.java
  27. +2 −2 src/main/java/jenkins/plugins/publish_over_ssh/options/SshOverridePublisherLabelDefaults.java
  28. +2 −2 src/main/java/jenkins/plugins/publish_over_ssh/options/SshOverrideRetryDefaults.java
  29. +2 −2 src/main/java/jenkins/plugins/publish_over_ssh/options/SshOverrideTransferDefaults.java
  30. +3 −3 src/test/java/jenkins/plugins/publish_over_ssh/jenkins/JenkinsTestHelper.java
  31. +2 −1 src/test/java/jenkins/plugins/publish_over_ssh/jenkins/LegacyConfigurationTest.java
@@ -0,0 +1,2 @@
// Build the plugin using https://github.com/jenkins-infra/pipeline-library
buildPlugin()
@@ -5,4 +5,4 @@ send artifacts to an SSH server (using SFTP) and/or execute commands over SSH

For more information, visit the wiki page:

https://wiki.jenkins-ci.org/display/JENKINS/Publish+Over+SSH+Plugin
https://wiki.jenkins.io/display/JENKINS/Publish+Over+SSH+Plugin
47 pom.xml
@@ -30,7 +30,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.19</version>
<version>3.2</version>
</parent>

<groupId>org.jenkins-ci.plugins</groupId>
@@ -43,7 +43,8 @@

<properties>
<java.net.id>bap</java.net.id>
<jenkins.version>1.580.1</jenkins.version>
<jenkins.version>1.625.3</jenkins.version>
<java.level>7</java.level>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<findbugs.failOnError>false</findbugs.failOnError>
</properties>
@@ -65,20 +66,14 @@

<dependencies>
<dependency>
<groupId>com.jcraft</groupId>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jsch</artifactId>
<version>0.1.53</version>
<version>0.1.54.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>publish-over</artifactId>
<version>0.18</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
<version>0.21</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
@@ -98,16 +93,9 @@
<version>2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-war</artifactId>
<type>war</type>
<version>${jenkins.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
@@ -129,21 +117,6 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
@@ -162,7 +135,6 @@
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<!-- <version>1.67</version> -->
<extensions>true</extensions>
<configuration>
<compatibleSinceVersion>0.3</compatibleSinceVersion>
@@ -171,7 +143,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<!-- <version>1.7</version> -->
<executions>
<execution>
<id>add-eclipse-sources</id>
@@ -255,14 +226,14 @@
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
</project>
@@ -26,6 +26,7 @@

import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.Run;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
@@ -47,7 +48,7 @@ public BapSshAlwaysRunPublisherPlugin(final ArrayList<BapSshPublisher> publisher
}

@Override
protected boolean isBuildGoodEnoughToRun(final AbstractBuild<?, ?> build, final PrintStream console) {
protected boolean isBuildGoodEnoughToRun(final Run<?, ?> build, final PrintStream console) {
return true;
}

@@ -32,6 +32,7 @@
import hudson.model.Hudson;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Builder;
import jenkins.model.Jenkins;
import jenkins.plugins.publish_over.BPPlugin;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
@@ -100,7 +101,7 @@ public String getDisplayName() {
return Messages.builder_descriptor_displayName();
}
public BapSshPublisherPlugin.Descriptor getPublisherDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapSshPublisherPlugin.Descriptor.class);
return Jenkins.getActiveInstance().getDescriptorByType(BapSshPublisherPlugin.Descriptor.class);
}
}

@@ -26,6 +26,7 @@

import hudson.model.Describable;
import hudson.model.Hudson;
import jenkins.model.Jenkins;
import jenkins.plugins.publish_over_ssh.descriptor.BapSshCommonConfigurationDescriptor;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
@@ -51,7 +52,7 @@ public boolean isDisableAllExec() {
}

public BapSshCommonConfigurationDescriptor getDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapSshCommonConfigurationDescriptor.class);
return Jenkins.getActiveInstance().getDescriptorByType(BapSshCommonConfigurationDescriptor.class);
}

protected EqualsBuilder addToEquals(final EqualsBuilder builder, final BapSshCommonConfiguration that) {
@@ -25,6 +25,7 @@
package jenkins.plugins.publish_over_ssh;

import hudson.model.Hudson;
import jenkins.model.Jenkins;
import jenkins.plugins.publish_over.Credentials;
import jenkins.plugins.publish_over_ssh.descriptor.BapSshCredentialsDescriptor;
import org.apache.commons.lang.builder.EqualsBuilder;
@@ -50,7 +51,7 @@ public String getUsername() {
}

public BapSshCredentialsDescriptor getDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapSshCredentialsDescriptor.class);
return Jenkins.getActiveInstance().getDescriptorByType(BapSshCredentialsDescriptor.class);
}

protected EqualsBuilder addToEquals(final EqualsBuilder builder, final BapSshCredentials that) {
@@ -33,6 +33,7 @@
import java.util.ArrayList;
import java.util.Properties;

import jenkins.model.Jenkins;
import jenkins.plugins.publish_over.*;
import jenkins.plugins.publish_over_ssh.descriptor.BapSshHostConfigurationDescriptor;
import org.apache.commons.lang.StringUtils;
@@ -434,7 +435,7 @@ protected JSch createJSch() {
}

public BapSshHostConfigurationDescriptor getDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapSshHostConfigurationDescriptor.class);
return Jenkins.getActiveInstance().getDescriptorByType(BapSshHostConfigurationDescriptor.class);
}

protected EqualsBuilder addToEquals(final EqualsBuilder builder, final BapSshHostConfiguration that) {
@@ -27,7 +27,7 @@
import hudson.Extension;
import hudson.model.Describable;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import jenkins.model.Jenkins;
import jenkins.plugins.publish_over.ParamPublish;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
@@ -45,7 +45,7 @@ public BapSshParamPublish(final String parameterName) {
}

public BapSshParamPublishDescriptor getDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapSshParamPublishDescriptor.class);
return Jenkins.getActiveInstance().getDescriptorByType(BapSshParamPublishDescriptor.class);
}

public boolean equals(final Object that) {
@@ -29,9 +29,9 @@
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
import hudson.model.Hudson;
import hudson.tasks.BuildWrapper;
import hudson.tasks.BuildWrapperDescriptor;
import jenkins.model.Jenkins;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
@@ -106,7 +106,7 @@ public String getDisplayName() {
return Messages.postBuild_descriptor_displayName();
}
public BapSshPublisherPlugin.Descriptor getPublisherDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapSshPublisherPlugin.Descriptor.class);
return Jenkins.getActiveInstance().getDescriptorByType(BapSshPublisherPlugin.Descriptor.class);
}
}

@@ -29,9 +29,9 @@
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
import hudson.model.Hudson;
import hudson.tasks.BuildWrapper;
import hudson.tasks.BuildWrapperDescriptor;
import jenkins.model.Jenkins;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
@@ -100,7 +100,7 @@ public String getDisplayName() {
return Messages.preBuild_descriptor_displayName();
}
public BapSshPublisherPlugin.Descriptor getPublisherDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapSshPublisherPlugin.Descriptor.class);
return Jenkins.getActiveInstance().getDescriptorByType(BapSshPublisherPlugin.Descriptor.class);
}
}

@@ -29,11 +29,11 @@
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
import hudson.model.Hudson;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Notifier;
import hudson.tasks.Publisher;
import jenkins.model.Jenkins;
import jenkins.plugins.publish_over.BPPlugin;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
@@ -107,7 +107,7 @@ public String getDisplayName() {
return Messages.promotion_descriptor_displayName();
}
public BapSshPublisherPlugin.Descriptor getPublisherDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapSshPublisherPlugin.Descriptor.class);
return Jenkins.getActiveInstance().getDescriptorByType(BapSshPublisherPlugin.Descriptor.class);
}
}

@@ -26,6 +26,7 @@

import hudson.model.Describable;
import hudson.model.Hudson;
import jenkins.model.Jenkins;
import jenkins.plugins.publish_over.BapPublisher;
import jenkins.plugins.publish_over_ssh.descriptor.BapSshPublisherDescriptor;
import org.apache.commons.lang.builder.EqualsBuilder;
@@ -71,7 +72,7 @@ public BapSshCredentials getSshCredentials() {
}

public BapSshPublisherDescriptor getDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapSshPublisherDescriptor.class);
return Jenkins.getActiveInstance().getDescriptorByType(BapSshPublisherDescriptor.class);
}

public boolean equals(final Object that) {
@@ -27,7 +27,7 @@
import hudson.Extension;
import hudson.model.Describable;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import jenkins.model.Jenkins;
import jenkins.plugins.publish_over.PublisherLabel;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
@@ -45,7 +45,7 @@ public BapSshPublisherLabel(final String label) {
}

public BapSshPublisherLabelDescriptor getDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapSshPublisherLabelDescriptor.class);
return Jenkins.getActiveInstance().getDescriptorByType(BapSshPublisherLabelDescriptor.class);
}

public boolean equals(final Object that) {
@@ -27,6 +27,8 @@
import hudson.Extension;
import hudson.model.Hudson;
import java.util.ArrayList;

import jenkins.model.Jenkins;
import jenkins.plugins.publish_over.BPPlugin;
import jenkins.plugins.publish_over.BPPluginDescriptor;
import jenkins.plugins.publish_over_ssh.descriptor.BapSshPublisherPluginDescriptor;
@@ -74,7 +76,7 @@ public String toString() {

@Override
public Descriptor getDescriptor() {
return Hudson.getInstance().getDescriptorByType(Descriptor.class);
return Jenkins.getActiveInstance().getDescriptorByType(Descriptor.class);
}

public BapSshHostConfiguration getConfiguration(final String name) {
@@ -27,8 +27,8 @@
import hudson.Extension;
import hudson.model.Describable;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.util.FormValidation;
import jenkins.model.Jenkins;
import jenkins.plugins.publish_over.Retry;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
@@ -47,7 +47,7 @@ public BapSshRetry(final int retries, final long retryDelay) {
}

public BapSshRetryDescriptor getDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapSshRetryDescriptor.class);
return Jenkins.getActiveInstance().getDescriptorByType(BapSshRetryDescriptor.class);
}

public boolean equals(final Object that) {
@@ -26,7 +26,7 @@

import hudson.Util;
import hudson.model.Describable;
import hudson.model.Hudson;
import jenkins.model.Jenkins;
import jenkins.plugins.publish_over.BPTransfer;
import jenkins.plugins.publish_over_ssh.descriptor.BapSshTransferDescriptor;
import org.apache.commons.lang.builder.EqualsBuilder;
@@ -86,7 +86,7 @@ public void setUseAgentForwarding(boolean value) {
}

public BapSshTransferDescriptor getDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapSshTransferDescriptor.class);
return Jenkins.getActiveInstance().getDescriptorByType(BapSshTransferDescriptor.class);
}

protected HashCodeBuilder addToHashCode(final HashCodeBuilder builder) {
@@ -27,7 +27,6 @@
import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.model.Item;
import hudson.security.AccessControlled;
import hudson.util.FormValidation;
@@ -80,7 +79,7 @@ public FormValidation doTestConnection(@QueryParameter final String configName,
final BapSshCredentials credentials = new BapSshCredentials(username, encryptedPassphrase, key, keyPath);
final BPBuildInfo buildInfo = BapSshPublisherPluginDescriptor.createDummyBuildInfo();
buildInfo.put(BPBuildInfo.OVERRIDE_CREDENTIALS_CONTEXT_KEY, credentials);
final BapSshPublisherPlugin.Descriptor pluginDescriptor = Hudson.getInstance().getDescriptorByType(
final BapSshPublisherPlugin.Descriptor pluginDescriptor = Jenkins.getActiveInstance().getDescriptorByType(
BapSshPublisherPlugin.Descriptor.class);
final BapSshHostConfiguration hostConfig = pluginDescriptor.getConfiguration(configName);
return BapSshPublisherPluginDescriptor.validateConnection(hostConfig, buildInfo);

0 comments on commit 7f95273

Please sign in to comment.
You can’t perform that action at this time.