Maintainers

Dependencies

Publish Over ...

Please read Publish Over first. Common configuration options that are documented in the Publish Over wiki page will not be repeated here.

Features

SCP - Send files over SSH (SFTP)

Execute commands on a remote server (can be disabled for a server configuration, or for the whole plugin)

Use username and password (keyboard-interactive) or public key authentication

Passwords/passphrases are encrypted in the configuration files and in the UI

SSH SFTP/ SSH Exec can be used as a build step during the build process (Freestyle and Matrix projects)

SSH before a (maven) project build, or to run after a build whether the build was successful or not (see Build wrappers below)

The plugin is "promotion aware" (send files directly from the artifacts directory of the build that is being promoted) see Promotions

Optionally override the authentication credentials for each server in the job configuration (or provide them if they have not been provided for that server in the global configuration)

Optionally retry if the transfer of files fails (useful for flakey connections)

Enable the command/ script to be executed in a pseudo TTY

Build wrappers

There will be two new options in the Build Environment section of the job configuration

Send files or execute commands over SSH before the build starts This allows SSH to be used before a build begins, but after the workspace has been configured and source checked out Most useful for maven project types

Send files or execute commands over SSH after the build runs As long as the build was attempted, this will run after the build finishes, and will run whether the build is successful or not This allows cleanup or shutdown of services started before or during the build Use the publisher (Send build artifacts over SSH in Post-build Actions) to publish build artifacts from succesful builds

Configure

Create host configurations in the main Jenkins configuration

From the Jenkins home ﻿page, click "Manage Jenkins" and then click on "Configure System"

Find the SSH section (as below)

This configures the default key that will be used by all of the SSH configurations. The simplest way to configure the key is to paste an unencrypted key into the Key box. To configure, set either the path to a file containing the key or paste the key into the Key field. If you enter data into both Path to key and Key, the pasted Key will take precedence and the Path to file will be ignored.

Unencrypted keys

If you plan to give read access to the Jenkins configuration page to non administrators, then you should ensure that you only use private keys encrypted with strong passphrases. The passphrase itself will be encrypted when the configuration is saved, and will also be encrypted in the UI so that the value cannot be read.

Passphrase

If the key is encrypted with a passphrase then set it here.

Path to file

The location, on the Jenkins master, of the private SSH key to use. The path can be an absolute path to the key, or relative to the JENKINS_HOME directory.

Key

Paste the private key into this box. The key should include both the header and footer lines (----) and everything in between.

Disable exec

This option will remove the ability to execute commands from this plugin. If this option is checked, then the Disable exec option in the Advanced section of an SSH Server will be ignored.

Configure a job to Publish Over SSH

Exec command

If there is anything in this configuration box then it will be executed on the remote server. If Source files are configured, then the files will be transfered before the Exec command is executed. If the exit status of the command is not zero, then the publish will fail. STDOUT and STDERR from the command execution are recorded in the Jenkins console.

Source files, Exec command

You must configure Source files, Exec command or both. If neither Source files nor Exec command are configured, the publish will fail. If the Source files box is empty then no files will be transferred.

Environment variables

Source files, Remove prefix, Remote directory and Exec command can all use the Jenkins environment variables and build parameters.