Skip to content

Commit

Permalink
Fix JENKINS-27963
Browse files Browse the repository at this point in the history
Added @symbol annotations and cleaned up the constructors a bit.
  • Loading branch information
slide committed Feb 25, 2018
1 parent c0679fe commit 8a78eeb
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 11 deletions.
8 changes: 7 additions & 1 deletion pom.xml
Expand Up @@ -31,6 +31,7 @@
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.2</version>
<relativePath />
</parent>

<groupId>org.jenkins-ci.plugins</groupId>
Expand Down Expand Up @@ -68,13 +69,18 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54.1</version>
<version>0.1.54.2</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>publish-over</artifactId>
<version>0.21</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Expand Up @@ -146,7 +146,6 @@ public final void setPassword(final String password) {
keyInfo.setPassphrase(password);
}

@DataBoundSetter
@Override
public final String getEncryptedPassword() {
return keyInfo.getEncryptedPassphrase();
Expand All @@ -159,10 +158,12 @@ public void setEncryptedPassword(final String encryptedPassword) {

public String getKeyPath() { return keyInfo.getKeyPath(); }

@DataBoundSetter
public void setKeyPath(final String keyPath) { keyInfo.setKeyPath(keyPath); }

public String getKey() { return keyInfo.getKey(); }

@DataBoundSetter
public void setKey(final String key) { keyInfo.setKey(key); }

public boolean isOverrideKey() { return overrideKey; }
Expand Down
Expand Up @@ -25,16 +25,20 @@
package jenkins.plugins.publish_over_ssh;

import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
import hudson.model.Run;
import hudson.model.TaskListener;
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 jenkins.tasks.SimpleBuildStep;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
Expand All @@ -45,7 +49,7 @@
import java.util.ArrayList;

@SuppressWarnings("PMD.LooseCoupling") // serializable
public class BapSshPromotionPublisherPlugin extends Notifier {
public class BapSshPromotionPublisherPlugin extends Notifier implements SimpleBuildStep {

private final BapSshPublisherPlugin delegate;

Expand All @@ -58,9 +62,9 @@ public BapSshPromotionPublisherPlugin(final ArrayList<BapSshPublisher> publisher
}

@Override
public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher, final BuildListener listener)
public void perform(final Run<?, ?> run, final FilePath ws, final Launcher launcher, final TaskListener listener)
throws InterruptedException, IOException {
return delegate.perform(build, launcher, listener);
delegate.perform(run, ws, launcher, listener);
}

public BapSshPublisherPlugin getDelegate() {
Expand Down
Expand Up @@ -36,26 +36,82 @@
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;


@SuppressWarnings({ "PMD.TooManyMethods", "PMD.LooseCoupling" })
public class BapSshPublisherPlugin extends BPPlugin<BapSshPublisher, BapSshClient, BapSshCommonConfiguration> {

private static final long serialVersionUID = 1L;

@DataBoundConstructor
public BapSshPublisherPlugin(final ArrayList<BapSshPublisher> publishers, final boolean continueOnError, final boolean failOnError,
final boolean alwaysPublishFromMaster, final String masterNodeName,
final BapSshParamPublish paramPublish) {
super(Messages.console_message_prefix(), publishers, continueOnError, failOnError, alwaysPublishFromMaster, masterNodeName,
paramPublish);
}

@DataBoundConstructor
public BapSshPublisherPlugin() {
super(Messages.console_message_prefix());
}

public BapSshParamPublish getParamPublish() {
return (BapSshParamPublish) getDelegate().getParamPublish();
}

@DataBoundSetter
public void setParamPublish(final BapSshParamPublish paramPublish) {
this.getDelegate().setParamPublish(paramPublish);
}

public List<BapSshPublisher> getPublishers() {
return this.getDelegate().getPublishers();
}

@DataBoundSetter
public void setPublishers(final ArrayList<BapSshPublisher> publishers) {
this.getDelegate().setPublishers(publishers);
}

public boolean isContinueOnError() {
return this.getDelegate().isContinueOnError();
}

@DataBoundSetter
public void setContinueOnError(final boolean continueOnError) {
this.getDelegate().setContinueOnError(continueOnError);
}

public boolean isFailOnError() {
return this.getDelegate().isFailOnError();
}

@DataBoundSetter
public void setFailOnError(final boolean failOnError) {
this.getDelegate().setFailOnError(failOnError);
}

public boolean isAlwaysPublishFromMaster() {
return this.getDelegate().isAlwaysPublishFromMaster();
}

@DataBoundSetter
public void setAlwaysPublishFromMaster(final boolean alwaysPublishFromMaster) {
this.getDelegate().setAlwaysPublishFromMaster(alwaysPublishFromMaster);
}

public String getMasterNodeName() {
return this.getDelegate().getMasterNodeName();
}

@DataBoundSetter
public void setMasterNodeName(final String masterNodeName) {
this.getDelegate().setMasterNodeName(masterNodeName);
}

@Override
public boolean equals(final Object that) {
if (this == that) return true;
Expand Down Expand Up @@ -83,7 +139,7 @@ public BapSshHostConfiguration getConfiguration(final String name) {
return getDescriptor().getConfiguration(name);
}

@Extension
@Extension @Symbol("sshPublisher")
public static class Descriptor extends BapSshPublisherPluginDescriptor {
@Override
public Object readResolve() {
Expand Down
23 changes: 21 additions & 2 deletions src/main/java/jenkins/plugins/publish_over_ssh/BapSshTransfer.java
Expand Up @@ -52,7 +52,7 @@ public class BapSshTransfer extends BPTransfer implements Describable<BapSshTran
this(sourceFiles, null, remoteDirectory, removePrefix, remoteDirectorySDF, flatten, execCommand, execTimeout, false, false, false, null);
}

@DataBoundConstructor
@Deprecated
public BapSshTransfer(final String sourceFiles, final String excludes, final String remoteDirectory, final String removePrefix,
final boolean remoteDirectorySDF, final boolean flatten, final String execCommand, final int execTimeout,
final boolean usePty, final boolean noDefaultExcludes, final boolean makeEmptyDirs, final String patternSeparator) {
Expand All @@ -63,10 +63,25 @@ public BapSshTransfer(final String sourceFiles, final String excludes, final Str
this.useAgentForwarding = false;
}

@DataBoundConstructor
public BapSshTransfer(final String sourceFiles) {
super(sourceFiles, null, null, null, false, false);
}

public String getExecCommand() { return execCommand; }

@DataBoundSetter
public void setExecCommand(String execCommand) {
this.execCommand = execCommand;
}

public int getExecTimeout() { return execTimeout; }

@DataBoundSetter
public void setExecTimeout(int execTimeout) {
this.execTimeout = execTimeout;
}

public boolean hasExecCommand() {
return Util.fixEmptyAndTrim(getExecCommand()) != null;
}
Expand All @@ -75,12 +90,16 @@ public boolean isUsePty() {
return usePty;
}

@DataBoundSetter
public void setUsePty(boolean usePty) {
this.usePty = usePty;
}

public boolean isUseAgentForwarding() {
return useAgentForwarding;
}

@DataBoundSetter
@Restricted(value = NoExternalUse.class)
public void setUseAgentForwarding(boolean value) {
useAgentForwarding = value;
}
Expand Down
Expand Up @@ -30,8 +30,9 @@
import jenkins.plugins.publish_over_ssh.BapSshPublisher;
import jenkins.plugins.publish_over_ssh.BapSshPublisherPlugin;
import jenkins.plugins.publish_over_ssh.Messages;
import org.jenkinsci.Symbol;

@Extension
@Extension @Symbol("sshPublisherDesc")
public class BapSshPublisherDescriptor extends Descriptor<BapSshPublisher> {

public BapSshPublisherDescriptor() {
Expand Down
Expand Up @@ -35,9 +35,10 @@
import jenkins.plugins.publish_over_ssh.BapSshPublisherPlugin;
import jenkins.plugins.publish_over_ssh.BapSshTransfer;
import jenkins.plugins.publish_over_ssh.Messages;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.QueryParameter;

@Extension
@Extension @Symbol("sshTransfer")
public class BapSshTransferDescriptor extends Descriptor<BapSshTransfer> {

public BapSshTransferDescriptor() {
Expand Down

0 comments on commit 8a78eeb

Please sign in to comment.