Skip to end of metadata
Go to start of metadata

Plugin Information

View SSH on the plugin site for more information.

Older versions of this plugin may not be safe to use. Please review the following warnings before using an older version:

Plugin info

This Plugin was derived from the very cool SCP Plugin.You can use the SSH Plugin to run shell commands on a remote machine via ssh.


Usage

First go to the global configuration page and add a SSH site.

For your job select a configured site and enter the shell commands that should be executetd before and after the build.

Log will look like this.


TODO

  • i18n
  • we also need a post deploy script (ask some of the core team how to do that)
  • investigate stop behavior of Hudson jobs using the ssh Plugin
  • use same sites as scp plugin (plugin dependencies???)
  • ...

 

Changelog

Version 2.6.1 (April 13 2018)
  • [JENKINS-19973] Option to hide ssh command in log

Version 2.6 (April 7 2018)
  • [JENKINS-46172] Handle NPE when not all fields are specified & save only properly configured sites

  • [JENKINS-10128] Set build to UNSTABLE when no SSH site is configured instead of NPE
  • Add Jenkinsfile to plugin
  • bump ssh-credentials dependency to 1.12
  • Add ajax validation to essential ssh host fields

INFO: the "Add Credentials" button for SSH Site don't work in recent Jenkins 2.x versions - this will be fixed in upcoming 3.0 version.
(major version since plugin will have to migrate it's configuration to new format)

Version 2.5 (July 8 2017)
  • [JENKINS-21436] Integrate with the SSH Credentials Plugin; previous credentials are migrated

  • [JENKINS-23231] Add timeout parameter

  • [JENKINS-24913] Don't show sensitive build variables in console log

  • [JENKINS-12191] Restore resolving hostname from environment variables

  • [JENKINS-12191] Support build variables (substitution variables) during command execution (env variables are exported before the script)

  • [JENKINS-24402] Updated to latest version of JSch (0.1.54) to support modern algorithms

  • Pull JSch dependency via Jenkins hosted jsch-plugin to use recommended way of getting common dependencies in Jenkins

  • Set Jenkins 1.609.3 as the oldest supported version

  • Show warning for missing parameters during ajax form validation

  • Fix security issue

Due to added integration with SSH Credentials Plugin, this version might NOT be fully compatibile with previous version. Sorry!

Please backup your org.jvnet.hudson.plugins.SSHBuildWrapper.xml before upgrading to version 2.5.

Version 2.4 (Jan 08 2014)
  • ability to use variables when defining SSH host
  • miscellaneous fixes
  • added keep alive interval
Version 2.3 (Sep 24 2012)
Version 2.2 (Sep 03 2012)
Version 2.1 (Aug 14 2012)
  • configurable pty mode
Version 2.0 (Jun 26, 2012)
  • support multiple sites on the same machine
Version 1.6 (Jun 24, 2012)
  • support parameterized builds
Version 1.3 (Jun 25, 2011)
Version 1.2 (Feb 17, 2011)
  • Fix to avoid executing empty script.
Version 1.1 (Jun 2, 2010)
  • Removed isEmpty() for 1.5 comp; better input areas
Version 1.0 (Feb 24, 2010)
  • Initial release.

25 Comments

  1. I like this plugin but it does not take parameters like $BUILD_NUMBER  of $JOB_NAME  I'm also  not able to  stop the  hudson  job when using this  plugin.

  2. Unknown User (aleori79)

    I am having the same problem, even the scrip I am calling takes only 15 secs, the Hudson Job never stops by

    itself or manually. I have to restart the server.

    Any idea, how to solve this.?

  3. Unknown User (magny)

    I have the same problem with the parameters aswell.. could you please support this in a upcoming version

    thanks Andreas

  4. A timeout setting with a default result (success or failure) would be enough for now.
    Thanks...

    (redirecting both outputs 1> /dev/null 2> /dev/null it works)

  5. Unknown User (mithun_shenoy@intuit.com)

    This plugin rocks!!! But pls tell me as to when the Environment variables like $BUILD_NUMBER will be supported?

  6. Since I upgrade Hudson to 1.367 this plugin is not working any more.
    It's something about CR/LF. I'm runing Hudson on Windows

  7. I need to connect to one host using 7 different users and the plugin just does not support it.

    - there is no field where you can assign a name or an identifier to a host, so the list of hosts looks pretty confusing in my case (all entries are the same).

    - the plugin always connects to the first host from my list, no matter which one I've actually chosen.

    Please add labels... you'll make my life a whole lot easier...

  8. This plugin is great. However since all my jobs are parametized builds, it does not recognize any parametized parameters when I reference them in the pre/post build script.

    We will only be able to use this once parametized parameters are recognized.

  9. Unknown User (stefan.thurnherr@gmail.com)

    Nice plugin - the big missing feature is that parametrized parameters are currently not supported.I'll have to wait for that feature to be implemented before we can use the plugin.

  10. Would be great to have a check box to enable a pseudo terminal (setPty) .

  11. I tried "svn co" command using this plugin and it seems to not respond . Exits with error status = 127

    Running jenkins on RHEL5.

  12. Not being able to use Jenkins parameters remotely is a deal breaker for us. Did anybody find a way around this?

  13. I have an issue. It seems that the SSH plugin presumes that the shell is bourne shell? However, in my case it is actually tcsh and this is causing some problems.

    I am interested in some of the jenkins environment variables such as NODE_NAME, and this plugin is smart enough to know that (because I am referencing to this environment variable in the build section of the plugin in order to navigate to a directory on the slave). So it will set the jenkins specific environment variable before the shell scripts and such in the build section are executed. Sounds good so far. However, it tries to do an export NODE_NAME =  ${NODE_NAME} and of course it fails as this is not recognized in tcsh. It should have been setenv NODE_NAME ${NODE_NAME}

    . Could you update plugin and check what type of shell is default and then set up the environment variables accordingly

    1. That's right. The "export" solution for parameterised builds won't work on VMS either, which would only understand DEFINE PARAMETER ${PARAMETER}

      The problem seems to be the hard-coded command in VariableReplacerUtil.java that gets executed before the actual build:

      sb.append("export " + variable + "=\"" + vars.get(variable) + "\"\n");

      The VariableReplacerUtil seems to already replace the parameter references inside the command strings anyway, so exporting these variables seems to be a redundant step that perhaps can be avoided altogether.

  14. Those struggling to execute builds with parameters(esp while running .bat scripts on a remote windows server via ssh plugin) try using a '\' (backslash without quotes) just before the variable name, without any space. See example below:

    We run a job on a windows server which does a database import using a .bat file, using a parameterized build

    We use use a variable FileName (which is the .dmp file name to be used in import)

    echo \$FileName

    run_import.bat TestDB1 \$FileName

    Please let me know if this helps.

  15. When I use this plugin to transfer files from Jenkins to another machine via the "Transfer Set Source files", the execute permissions of the files don't seem to carry over to the destination set of files.

    Both Jenkins and the destination server that I've established an SSH connection with are running on Ubuntu 12.04.  When I run the scp command manually (i.e. not from the Jenkins app) from my Jenkins server to the destination server the permissions do in fact carry over properly.  Does the plugin not use the scp command internally? Does it do something that would cause this to happen?

    Any help would be appreciated.

    1. Sorry posted this to the wrong plugin page.

  16. To the author of this plugin. It would be appreciated if the plugin was placed under some kind of license.

    MIT License is the most common for Jenkins plugins.

  17. How do I use variables when defining SSH host? I have tried using $VAR and ${VAR} without success.

    version 2.4

  18. While trying to install GIT plugins in Jenkin8.5, its failing with ssh-credentails recreation error. Already ssh-credentials is present there. I tried to delete it from jenkins85 folder but It showing error deleting file '.nfsXXXXX'

  19. Showstopper: The Add button for creating credentials has no effect.  No dialog, no nothing.

    SSH Plugin 2.5

    Credentials Plugin 2.1.16

    Jenkins 2.89

    Chrome Browser

     

    The Add button for credentials does work for every other plugin I have that integrates with the Credentials Plugin.

     

    1. Please create a ticket in JIRA with issue description / screenshots.

      If you could also check if there are JavaScript errors in Browser's Developer Console / Tools it would be great.

      1. I am having this issue as well, see attached JS error.

        Not sure which "JIRA" you mean to put a ticket.

  20. Is there any way of marking a job as failing when something happens during the ssh commands?

    1. I answer myself. Just keep the output value for the command like this :

       

      mycommand
      status=$?
      if [ $status != 0 ]; then
      echo "there was an error running mycommand"
      exit $status
      fi

Write a comment…