diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 4491640..1588327 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -3,8 +3,8 @@ == 1.0.0 (Unreleased) * Initial release. * Supported Steps. -** sshExecuteCommand -** sshExecuteScript +** sshCommand +** sshScript ** sshGet ** sshPut ** sshRemove diff --git a/README.adoc b/README.adoc index c0ccf80..e0f88d4 100644 --- a/README.adoc +++ b/README.adoc @@ -144,7 +144,7 @@ Most of the steps in this plugin require a common step variable called `remote`, The following pipeline steps are available with the initial version of this plugin. -=== sshExecuteCommand +=== sshCommand This step executes given command on remote node and responds with output. @@ -187,12 +187,12 @@ This step executes given command on remote node and responds with output. remote.password = 'password' remote.allowAnyHosts = true stage('Remote SSH') { - sshExecuteCommand remote: remote, command: "ls -lrt" - sshExecuteCommand remote: remote, command: "for i in {1..5}; do echo -n \"Loop \$i \"; date ; sleep 1; done" + sshCommand remote: remote, command: "ls -lrt" + sshCommand remote: remote, command: "for i in {1..5}; do echo -n \"Loop \$i \"; date ; sleep 1; done" } ``` -=== sshExecuteScript +=== sshScript This step executes given script(file) on remote node and responds with output. @@ -232,7 +232,7 @@ This step executes given script(file) on remote node and responds with output. remote.allowAnyHosts = true stage('Remote SSH') { writeFile file: 'abc.sh', text: 'ls -lrt' - sshExecuteScript remote: remote, script: "abc.sh" + sshScript remote: remote, script: "abc.sh" } ``` @@ -390,17 +390,21 @@ node { remote.identityFile = identity stage("SSH Steps Rocks!") { writeFile file: 'abc.sh', text: 'ls' - sshExecuteCommand remote: remote, command: 'for i in {1..5}; do echo -n \"Loop \$i \"; date ; sleep 1; done' + sshCommand remote: remote, command: 'for i in {1..5}; do echo -n \"Loop \$i \"; date ; sleep 1; done' sshPut remote: remote, from: 'abc.sh', into: '.' sshGet remote: remote, from: 'abc.sh', into: 'bac.sh', override: true - sshExecuteScript remote: remote, script: 'abc.sh' + sshScript remote: remote, script: 'abc.sh' sshRemove remote: remote, path: 'abc.sh' } } } ``` -image::docs/static/ExampleWithCredentials.png[Example,300] +==== Classic View: +image::docs/static/ExampleWithCredentials.png[ExampleWithCredentials,900] + +==== Blue Ocean View: +image::docs/static/ExampleWithCredentialsBlueOcean.png[ExampleWithCredentialsBlueOcean,900] == Maintainers diff --git a/docs/static/ExampleWithCredentials.png b/docs/static/ExampleWithCredentials.png index e0f7aae..a112323 100644 Binary files a/docs/static/ExampleWithCredentials.png and b/docs/static/ExampleWithCredentials.png differ diff --git a/docs/static/ExampleWithCredentialsBlueOcean.png b/docs/static/ExampleWithCredentialsBlueOcean.png new file mode 100644 index 0000000..903930a Binary files /dev/null and b/docs/static/ExampleWithCredentialsBlueOcean.png differ diff --git a/src/main/java/org/jenkinsci/plugins/ssh/steps/ExecuteCommandStep.java b/src/main/java/org/jenkinsci/plugins/ssh/steps/CommandStep.java similarity index 74% rename from src/main/java/org/jenkinsci/plugins/ssh/steps/ExecuteCommandStep.java rename to src/main/java/org/jenkinsci/plugins/ssh/steps/CommandStep.java index 4079419..b5939db 100644 --- a/src/main/java/org/jenkinsci/plugins/ssh/steps/ExecuteCommandStep.java +++ b/src/main/java/org/jenkinsci/plugins/ssh/steps/CommandStep.java @@ -18,7 +18,7 @@ * * @author Naresh Rayapati */ -public class ExecuteCommandStep extends BasicSSHStep { +public class CommandStep extends BasicSSHStep { private static final long serialVersionUID = 7492916747486604582L; @@ -30,7 +30,7 @@ public class ExecuteCommandStep extends BasicSSHStep { private boolean sudo = false; @DataBoundConstructor - public ExecuteCommandStep(final String command) { + public CommandStep(final String command) { this.command = command; } @@ -44,7 +44,7 @@ public static class DescriptorImpl extends SSHStepDescriptorImpl { @Override public String getFunctionName() { - return "sshExecuteCommand"; + return "sshCommand"; } @Override @@ -57,29 +57,29 @@ public static class Execution extends SSHStepExecution { private static final long serialVersionUID = -5293952534324828128L; - protected Execution(final ExecuteCommandStep step, final StepContext context) + protected Execution(final CommandStep step, final StepContext context) throws IOException, InterruptedException { super(step, context); } @Override protected Object run() throws Exception { - ExecuteCommandStep step = (ExecuteCommandStep) getStep(); + CommandStep step = (CommandStep) getStep(); if (Util.fixEmpty(step.getCommand()) == null) { throw new IllegalArgumentException("command is null or empty"); } - return getLauncher().getChannel().call(new ExecuteCommandCallable(step, getListener())); + return getLauncher().getChannel().call(new CommandCallable(step, getListener())); } - private static class ExecuteCommandCallable extends SSHMasterToSlaveCallable { + private static class CommandCallable extends SSHMasterToSlaveCallable { - public ExecuteCommandCallable(final ExecuteCommandStep step, final TaskListener listener) { + public CommandCallable(final CommandStep step, final TaskListener listener) { super(step, listener); } @Override public Object execute() { - ExecuteCommandStep step = (ExecuteCommandStep) getStep(); + CommandStep step = (CommandStep) getStep(); return getService().executeCommand(step.getCommand(), step.isSudo()); } } diff --git a/src/main/java/org/jenkinsci/plugins/ssh/steps/GetStep.java b/src/main/java/org/jenkinsci/plugins/ssh/steps/GetStep.java index 2f7495c..d943434 100644 --- a/src/main/java/org/jenkinsci/plugins/ssh/steps/GetStep.java +++ b/src/main/java/org/jenkinsci/plugins/ssh/steps/GetStep.java @@ -87,7 +87,8 @@ protected Object run() throws Exception { intoPath = ws.child(step.getInto()); if (intoPath.exists() && !step.isOverride()) { - throw new IllegalArgumentException(intoPath.getRemote() + " already exist. Please set override to true just in case."); + throw new IllegalArgumentException( + intoPath.getRemote() + " already exist. Please set override to true just in case."); } return getLauncher().getChannel() diff --git a/src/main/java/org/jenkinsci/plugins/ssh/steps/ExecuteScriptStep.java b/src/main/java/org/jenkinsci/plugins/ssh/steps/ScriptStep.java similarity index 81% rename from src/main/java/org/jenkinsci/plugins/ssh/steps/ExecuteScriptStep.java rename to src/main/java/org/jenkinsci/plugins/ssh/steps/ScriptStep.java index bf0e259..907c668 100644 --- a/src/main/java/org/jenkinsci/plugins/ssh/steps/ExecuteScriptStep.java +++ b/src/main/java/org/jenkinsci/plugins/ssh/steps/ScriptStep.java @@ -18,7 +18,7 @@ * * @author Naresh Rayapati */ -public class ExecuteScriptStep extends BasicSSHStep { +public class ScriptStep extends BasicSSHStep { private static final long serialVersionUID = 7358533459289529723L; @@ -26,7 +26,7 @@ public class ExecuteScriptStep extends BasicSSHStep { private final String script; @DataBoundConstructor - public ExecuteScriptStep(final String script) { + public ScriptStep(final String script) { this.script = script; } @@ -40,7 +40,7 @@ public static class DescriptorImpl extends SSHStepDescriptorImpl { @Override public String getFunctionName() { - return "sshExecuteScript"; + return "sshScript"; } @Override @@ -53,14 +53,14 @@ public static class Execution extends SSHStepExecution { private static final long serialVersionUID = 6008070200393301960L; - protected Execution(final ExecuteScriptStep step, final StepContext context) + protected Execution(final ScriptStep step, final StepContext context) throws IOException, InterruptedException { super(step, context); } @Override protected Object run() throws Exception { - ExecuteScriptStep step = (ExecuteScriptStep) getStep(); + ScriptStep step = (ScriptStep) getStep(); FilePath ws = getContext().get(FilePath.class); assert ws != null; FilePath path; @@ -79,14 +79,14 @@ protected Object run() throws Exception { } return getLauncher().getChannel() - .call(new ExecuteScriptCallable(step, getListener(), path.getRemote())); + .call(new ScriptCallable(step, getListener(), path.getRemote())); } - private static class ExecuteScriptCallable extends SSHMasterToSlaveCallable { + private static class ScriptCallable extends SSHMasterToSlaveCallable { private final String script; - public ExecuteScriptCallable(final ExecuteScriptStep step, final TaskListener listener, + public ScriptCallable(final ScriptStep step, final TaskListener listener, final String script) { super(step, listener); this.script = script; diff --git a/src/main/resources/org/jenkinsci/plugins/ssh/steps/ExecuteCommandStep/config.jelly b/src/main/resources/org/jenkinsci/plugins/ssh/steps/CommandStep/config.jelly similarity index 100% rename from src/main/resources/org/jenkinsci/plugins/ssh/steps/ExecuteCommandStep/config.jelly rename to src/main/resources/org/jenkinsci/plugins/ssh/steps/CommandStep/config.jelly diff --git a/src/main/resources/org/jenkinsci/plugins/ssh/steps/ExecuteScriptStep/config.jelly b/src/main/resources/org/jenkinsci/plugins/ssh/steps/ScriptStep/config.jelly similarity index 100% rename from src/main/resources/org/jenkinsci/plugins/ssh/steps/ExecuteScriptStep/config.jelly rename to src/main/resources/org/jenkinsci/plugins/ssh/steps/ScriptStep/config.jelly diff --git a/src/test/java/org/jenkinsci/plugins/ssh/steps/ExecuteCommandStepTest.java b/src/test/java/org/jenkinsci/plugins/ssh/steps/CommandStepTest.java similarity index 84% rename from src/test/java/org/jenkinsci/plugins/ssh/steps/ExecuteCommandStepTest.java rename to src/test/java/org/jenkinsci/plugins/ssh/steps/CommandStepTest.java index 29f4ab9..9261daa 100644 --- a/src/test/java/org/jenkinsci/plugins/ssh/steps/ExecuteCommandStepTest.java +++ b/src/test/java/org/jenkinsci/plugins/ssh/steps/CommandStepTest.java @@ -26,13 +26,13 @@ import org.powermock.modules.junit4.PowerMockRunner; /** - * Unit test cases for ExecuteCommandStepTest class. + * Unit test cases for CommandStep class. * * @author Naresh Rayapati */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ExecuteCommandStepTest.class, SSHService.class}) -public class ExecuteCommandStepTest { +@PrepareForTest({CommandStepTest.class, SSHService.class}) +public class CommandStepTest { @Mock TaskListener taskListenerMock; @@ -49,7 +49,7 @@ public class ExecuteCommandStepTest { @Mock Launcher launcherMock; - ExecuteCommandStep.Execution stepExecution; + CommandStep.Execution stepExecution; @Before public void setup() throws IOException, InterruptedException { @@ -71,8 +71,8 @@ public void setup() throws IOException, InterruptedException { @Test public void testWithEmptyCommandThrowsIllegalArgumentException() throws Exception { - final ExecuteCommandStep step = new ExecuteCommandStep(""); - stepExecution = new ExecuteCommandStep.Execution(step, contextMock); + final CommandStep step = new CommandStep(""); + stepExecution = new CommandStep.Execution(step, contextMock); // Execute and assert Test. assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> { @@ -83,10 +83,10 @@ public void testWithEmptyCommandThrowsIllegalArgumentException() throws Exceptio @Test public void testSuccessfulExecuteCommand() throws Exception { - final ExecuteCommandStep step = new ExecuteCommandStep("ls -lrt"); + final CommandStep step = new CommandStep("ls -lrt"); // Since SSHService is a mock, it is not validating remote. - stepExecution = new ExecuteCommandStep.Execution(step, contextMock); + stepExecution = new CommandStep.Execution(step, contextMock); // Execute Test. stepExecution.run(); diff --git a/src/test/java/org/jenkinsci/plugins/ssh/steps/ExecuteScriptStepTest.java b/src/test/java/org/jenkinsci/plugins/ssh/steps/ScriptStepTest.java similarity index 86% rename from src/test/java/org/jenkinsci/plugins/ssh/steps/ExecuteScriptStepTest.java rename to src/test/java/org/jenkinsci/plugins/ssh/steps/ScriptStepTest.java index 2cfc49e..4fbd8f2 100644 --- a/src/test/java/org/jenkinsci/plugins/ssh/steps/ExecuteScriptStepTest.java +++ b/src/test/java/org/jenkinsci/plugins/ssh/steps/ScriptStepTest.java @@ -27,13 +27,13 @@ import org.powermock.modules.junit4.PowerMockRunner; /** - * Unit test cases for ExecuteScriptStep class. + * Unit test cases for ScriptStep class. * * @author Naresh Rayapati */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ExecuteScriptStepTest.class, SSHService.class, FilePath.class}) -public class ExecuteScriptStepTest { +@PrepareForTest({ScriptStepTest.class, SSHService.class, FilePath.class}) +public class ScriptStepTest { final String scriptName = "test.sh"; @@ -54,7 +54,7 @@ public class ExecuteScriptStepTest { @Mock FilePath filePathMock; - ExecuteScriptStep.Execution stepExecution; + ScriptStep.Execution stepExecution; @Before public void setup() throws IOException, InterruptedException { @@ -82,8 +82,8 @@ public void setup() throws IOException, InterruptedException { @Test public void testWithEmptyCommandThrowsIllegalArgumentException() throws Exception { - final ExecuteScriptStep step = new ExecuteScriptStep(""); - stepExecution = new ExecuteScriptStep.Execution(step, contextMock); + final ScriptStep step = new ScriptStep(""); + stepExecution = new ScriptStep.Execution(step, contextMock); // Execute and assert Test. assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> { @@ -94,10 +94,10 @@ public void testWithEmptyCommandThrowsIllegalArgumentException() throws Exceptio @Test public void testSuccessfulExecuteScript() throws Exception { - final ExecuteScriptStep step = new ExecuteScriptStep(scriptName); + final ScriptStep step = new ScriptStep(scriptName); // Since SSHService is a mock, it is not validating remote. - stepExecution = new ExecuteScriptStep.Execution(step, contextMock); + stepExecution = new ScriptStep.Execution(step, contextMock); // Execute Test. stepExecution.run();