diff --git a/Jenkinsfile b/Jenkinsfile index f0bdcc9..453a79f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,9 @@ #!/usr/bin/env groovy /* `buildPlugin` step provided by: https://github.com/jenkins-infra/pipeline-library */ -buildPlugin() \ No newline at end of file +buildPlugin( + useContainerAgent: true, + configurations: [ + [platform: 'linux', jdk: 21], + [platform: 'windows', jdk: 17], + ]) diff --git a/README.md b/README.md index a118b9b..eb384ff 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,21 @@ -ssh-plugin -=========== +# ssh-plugin -You can use the SSH Plugin to run shell commands on a remote machine via ssh. +## About + +This is a Jenkins plugin that allows for you to run operations with SSH. (I.e. commands, file management etc) + +## Usage Documentation and Examples More documentation available on the Jenkins wiki: https://wiki.jenkins-ci.org/display/JENKINS/SSH+Plugin -Contribute ------------- +## Building this project -Fork and send a pull request (or create an issue on GitHub or in JIRA) +```shell +mvn install +``` +## Contribute + +Fork and send a pull request (or create an issue on GitHub or in JIRA) diff --git a/pom.xml b/pom.xml index 094c31b..c1a4d9c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,94 +1,107 @@ - - 4.0.0 - Execute shell scripts on remote host -using ssh (pre and post build). -Based on the cool scp plugin. - - org.jenkins-ci.plugins - plugin - 1.609.3 - + + 4.0.0 + Execute shell scripts on remote host + using ssh (pre and post build). + Based on the cool scp plugin. + + + org.jenkins-ci.plugins + plugin + 4.86 + + + + 2.426.3 + + ssh + Jenkins SSH plugin + 2.7-SNAPSHOT + hpi + http://wiki.jenkins-ci.org/display/JENKINS/SSH+plugin - ssh - Jenkins SSH plugin - 2.7-SNAPSHOT - hpi - http://wiki.jenkins-ci.org/display/JENKINS/SSH+plugin + + + edmund_wagner + Edmund Wagner + + + ljader + Lukasz Jader + + - - - edmund_wagner - Edmund Wagner - - - ljader - Lukasz Jader - - - - - - org.jenkins-ci.plugins - jsch - 0.1.54.1 - + + + org.jenkins-ci.plugins + jsch + org.jenkins-ci.plugins ssh-credentials - 1.12 - + + + + + + io.jenkins.tools.bom + bom-2.426.x + 3208.vb_21177d4b_cd9 + import + pom + + + - - - - maven-release-plugin - - deploy - - - - org.jenkins-ci.tools - maven-hpi-plugin - true - - 2.5 - - - - + + + + maven-release-plugin + + deploy + + + + org.jenkins-ci.tools + maven-hpi-plugin + true + + 2.5 + + + + - - - maven.jenkins-ci.org - https://repo.jenkins-ci.org/releases/ - - - maven.jenkins-ci.org - https://repo.jenkins-ci.org/snapshots/ - - + + + maven.jenkins-ci.org + https://repo.jenkins-ci.org/releases/ + + + maven.jenkins-ci.org + https://repo.jenkins-ci.org/snapshots/ + + - - - - repo.jenkins-ci.org - https://repo.jenkins-ci.org/public/ - - + + + repo.jenkins-ci.org + https://repo.jenkins-ci.org/public/ + + - - - repo.jenkins-ci.org - https://repo.jenkins-ci.org/public/ - - + + + repo.jenkins-ci.org + https://repo.jenkins-ci.org/releases/ + + - - scm:git:git@github.com:jenkinsci/ssh-plugin.git - scm:git:git@github.com:jenkinsci/ssh-plugin.git - HEAD - + + scm:git:https://github.com/jenkinsci/ssh-plugin.git + scm:git:git@github.com:jenkinsci/ssh-plugin.git + HEAD + diff --git a/src/main/java/org/jvnet/hudson/plugins/SSHBuildWrapper.java b/src/main/java/org/jvnet/hudson/plugins/SSHBuildWrapper.java index ea4bd99..bd5d506 100644 --- a/src/main/java/org/jvnet/hudson/plugins/SSHBuildWrapper.java +++ b/src/main/java/org/jvnet/hudson/plugins/SSHBuildWrapper.java @@ -45,6 +45,7 @@ import com.cloudbees.plugins.credentials.CredentialsProvider; import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; import com.jcraft.jsch.JSchException; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; public final class SSHBuildWrapper extends BuildWrapper { @@ -211,6 +212,8 @@ public String getHelpFile() { } @Override + @SuppressFBWarnings(value = "NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE", + justification = "Javadoc promises req is always non-null") public BuildWrapper newInstance(StaplerRequest req, JSONObject formData) { return req.bindJSON(clazz, formData); } diff --git a/src/main/java/org/jvnet/hudson/plugins/VariableReplacerUtil.java b/src/main/java/org/jvnet/hudson/plugins/VariableReplacerUtil.java index f70a652..2dc52ef 100644 --- a/src/main/java/org/jvnet/hudson/plugins/VariableReplacerUtil.java +++ b/src/main/java/org/jvnet/hudson/plugins/VariableReplacerUtil.java @@ -19,10 +19,10 @@ public static String preludeWithEnvVars(String originalCommand, Map entry : vars.entrySet()) { //TODO handle case sensitivity for command and each variable - if (originalCommand.contains(variable) ) { - sb.append(variable).append("=\"").append(vars.get(variable)).append("\"\n"); + if (originalCommand.contains(entry.getKey()) ) { + sb.append(entry.getKey()).append("=\"").append(entry.getValue()).append("\"\n"); } } sb.append("\n"); @@ -36,9 +36,9 @@ public static String scrub(String command, Map vars, Set } vars.remove("_"); for (String sensitive : eyesOnlyVars) { - for (String variable : vars.keySet()) { - if (variable.equals(sensitive)) { - String value = vars.get(variable); + for (Map.Entry entry : vars.entrySet()) { + if (entry.getKey().equals(sensitive)) { + String value = vars.get(entry.getKey()); //TODO handle case sensitivity for command and each value if (command.contains(value)) { if (command.contains("\"" + value + "\"")) { diff --git a/src/main/resources/index.jelly b/src/main/resources/index.jelly index 17230b5..094279d 100644 --- a/src/main/resources/index.jelly +++ b/src/main/resources/index.jelly @@ -1,3 +1,4 @@ +
This plugin executes shell commands remotely using SSH protocol.
diff --git a/src/main/resources/org/jvnet/hudson/plugins/SSHBuildWrapper/config.jelly b/src/main/resources/org/jvnet/hudson/plugins/SSHBuildWrapper/config.jelly index 2bd6b4c..4ef5a00 100644 --- a/src/main/resources/org/jvnet/hudson/plugins/SSHBuildWrapper/config.jelly +++ b/src/main/resources/org/jvnet/hudson/plugins/SSHBuildWrapper/config.jelly @@ -1,3 +1,4 @@ + diff --git a/src/main/resources/org/jvnet/hudson/plugins/SSHBuildWrapper/global.jelly b/src/main/resources/org/jvnet/hudson/plugins/SSHBuildWrapper/global.jelly index e4cdc3a..cbb7a47 100644 --- a/src/main/resources/org/jvnet/hudson/plugins/SSHBuildWrapper/global.jelly +++ b/src/main/resources/org/jvnet/hudson/plugins/SSHBuildWrapper/global.jelly @@ -1,3 +1,4 @@ + diff --git a/src/main/resources/org/jvnet/hudson/plugins/SSHBuilder/config.jelly b/src/main/resources/org/jvnet/hudson/plugins/SSHBuilder/config.jelly index 2148173..aa6a2a8 100644 --- a/src/main/resources/org/jvnet/hudson/plugins/SSHBuilder/config.jelly +++ b/src/main/resources/org/jvnet/hudson/plugins/SSHBuilder/config.jelly @@ -1,3 +1,4 @@ + diff --git a/src/test/resources/org/jvnet/hudson/plugins/SSHBuildWrapperTest/credentialsForSameSiteAreMerged/config.xml b/src/test/resources/org/jvnet/hudson/plugins/SSHBuildWrapperTest/credentialsForSameSiteAreMerged/config.xml index 34cebd0..efd840b 100644 --- a/src/test/resources/org/jvnet/hudson/plugins/SSHBuildWrapperTest/credentialsForSameSiteAreMerged/config.xml +++ b/src/test/resources/org/jvnet/hudson/plugins/SSHBuildWrapperTest/credentialsForSameSiteAreMerged/config.xml @@ -1,13 +1,10 @@ - 1.609.3 + 2.320 1 NORMAL true - - hudson.model.Hudson.Read:anonymous - hudson.model.Item.Read:anonymous - + diff --git a/src/test/resources/org/jvnet/hudson/plugins/SSHBuildWrapperTest/loadAllThreePossibleSiteConfigs/config.xml b/src/test/resources/org/jvnet/hudson/plugins/SSHBuildWrapperTest/loadAllThreePossibleSiteConfigs/config.xml index 34cebd0..efd840b 100644 --- a/src/test/resources/org/jvnet/hudson/plugins/SSHBuildWrapperTest/loadAllThreePossibleSiteConfigs/config.xml +++ b/src/test/resources/org/jvnet/hudson/plugins/SSHBuildWrapperTest/loadAllThreePossibleSiteConfigs/config.xml @@ -1,13 +1,10 @@ - 1.609.3 + 2.320 1 NORMAL true - - hudson.model.Hudson.Read:anonymous - hudson.model.Item.Read:anonymous - + diff --git a/src/test/resources/org/jvnet/hudson/plugins/SSHBuildWrapperTest/loadConfigWorksFromOlder23Version/config.xml b/src/test/resources/org/jvnet/hudson/plugins/SSHBuildWrapperTest/loadConfigWorksFromOlder23Version/config.xml index 34cebd0..efd840b 100644 --- a/src/test/resources/org/jvnet/hudson/plugins/SSHBuildWrapperTest/loadConfigWorksFromOlder23Version/config.xml +++ b/src/test/resources/org/jvnet/hudson/plugins/SSHBuildWrapperTest/loadConfigWorksFromOlder23Version/config.xml @@ -1,13 +1,10 @@ - 1.609.3 + 2.320 1 NORMAL true - - hudson.model.Hudson.Read:anonymous - hudson.model.Item.Read:anonymous - +