Skip to content
Permalink
Browse files
[JENKINS-34336] Upgrade to parent pom 2.6. Fix failing tests, findbug…
…s errors and references to callable
  • Loading branch information
armfergom committed Apr 19, 2016
1 parent be49820 commit 45e1d5e3a9103a4d48d47407aedabd82b198667a
Showing 7 changed files with 17 additions and 101 deletions.
97 pom.xml
@@ -29,7 +29,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.532.2</version>
<version>2.6</version>
</parent>

<artifactId>ssh-credentials</artifactId>
@@ -65,11 +65,8 @@
</scm>

<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.findbugs.version>3.0.1</maven.findbugs.version>
<maven.findbugs.failure.strict>true</maven.findbugs.failure.strict>
<jenkins.version>1.580.1</jenkins.version>
<java.level>6</java.level>
</properties>

<repositories>
@@ -101,100 +98,12 @@
</dependency>
<!-- jenkins dependencies -->
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>0.12.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.6.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>(,2.1.0),(2.1.0,2.2.0),(2.2.0,)</version>
<message>Maven 2.1.0 and 2.2.0 produce incorrect GPG signatures and checksums respectively.</message>
</requireMavenVersion>
<requireMavenVersion>
<version>(,3.0),[3.0.4,)</version>
<message>Maven 3.0 through 3.0.3 inclusive do not pass correct settings.xml to Maven Release Plugin.</message>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<configuration>
<compatibleSinceVersion>1.0</compatibleSinceVersion>
</configuration>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${maven.findbugs.version}</version>
<configuration>
<xmlOutput>true</xmlOutput>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
<excludeFilterFile>src/findbugs/excludesFilter.xml</excludeFilterFile>
<failOnError>${maven.findbugs.failure.strict}</failOnError>
</configuration>
<executions>
<execution>
<id>run-findbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
@@ -30,13 +30,14 @@
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.model.BuildListener;
import hudson.model.Hudson;
import hudson.model.TaskListener;
import hudson.remoting.Callable;
import hudson.remoting.Channel;
import hudson.util.StreamTaskListener;
import jenkins.model.Jenkins;
import jenkins.security.MasterToSlaveCallable;
import net.jcip.annotations.GuardedBy;

import java.io.IOException;
@@ -180,6 +181,7 @@ public static <C, U extends StandardUsernameCredentials> SSHAuthenticator<C, U>
* @return a {@link SSHAuthenticator} that may or may not be able to successfully authenticate.
* @since 1.4
*/
@SuppressFBWarnings(value="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification="https://github.com/jenkinsci/jenkins/pull/2094")
@NonNull
public static <C, U extends StandardUsernameCredentials> SSHAuthenticator<C, U> newInstance(@NonNull C connection,
@NonNull U user,
@@ -194,7 +196,8 @@ public static <C, U extends StandardUsernameCredentials> SSHAuthenticator<C, U>
factories = Jenkins.getInstance().getExtensionList(SSHAuthenticatorFactory.class);
} else {
// if running on the slave, bring these factories over here
factories = Channel.current().call(new Callable<Collection<SSHAuthenticatorFactory>, IOException>() {
factories = Channel.current().call(new MasterToSlaveCallable<Collection<SSHAuthenticatorFactory>, IOException>() {

This comment has been minimized.

Copy link
@stephenc

stephenc Jun 9, 2016

Member

Should be SlaveToMasterCallable as this method is getting invoked on the slave also (though there are issues with trying to load the Jenkins class on the slave that need fixing)

@SuppressFBWarnings(value="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification="https://github.com/jenkinsci/jenkins/pull/2094")
public Collection<SSHAuthenticatorFactory> call() throws IOException {
return new ArrayList<SSHAuthenticatorFactory>(
Jenkins.getInstance().getExtensionList(SSHAuthenticatorFactory.class));
@@ -23,6 +23,7 @@
~ THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:entry title="${%Key}" field="privateKey">
<f:textarea/>
@@ -23,6 +23,7 @@
~ THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:entry title="${%File}" field="privateKeyFile">
<f:textbox/>
@@ -23,6 +23,7 @@
~ THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:st="jelly:stapler">
<f:entry title="${%Username}" field="username">
<f:textbox/>
@@ -33,6 +33,8 @@
import hudson.model.Hudson;
import hudson.remoting.Callable;
import hudson.security.ACL;
import jenkins.security.MasterToSlaveCallable;

import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Rule;
@@ -56,7 +58,7 @@ public class BasicSSHUserPrivateKeyTest {
// TODO would be more interesting to use a Docker fixture to demonstrate that the file load is happening only from the master side
assertEquals("[stuff]", r.createOnlineSlave().getChannel().call(new LoadPrivateKeys(key)));
}
private static class LoadPrivateKeys implements Callable<String,Exception> {
private static class LoadPrivateKeys extends MasterToSlaveCallable<String,Exception> {
private final SSHUserPrivateKey key;
LoadPrivateKeys(SSHUserPrivateKey key) {
this.key = key;
@@ -25,16 +25,15 @@

import com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator;
import com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticatorFactory;
import com.cloudbees.jenkins.plugins.sshcredentials.SSHUser;
import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPassword;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials;
import com.trilead.ssh2.Connection;
import com.trilead.ssh2.ServerHostKeyVerifier;
import hudson.model.Computer;
import hudson.model.Items;
import hudson.remoting.Callable;
import hudson.slaves.DumbSlave;
import jenkins.security.MasterToSlaveCallable;

import org.apache.sshd.SshServer;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.server.PasswordAuthenticator;
@@ -177,7 +176,7 @@ public boolean verifyServerHostKey(String hostname, int port, String serverHostK
}
}

private static final class RemoteConnectionTest implements Callable<Void, Exception> {
private static final class RemoteConnectionTest extends MasterToSlaveCallable<Void, Exception> {
private final int port;
private StandardUsernamePasswordCredentials user;

0 comments on commit 45e1d5e

Please sign in to comment.