The following plugin provides functionality available through Pipeline-compatible steps. Read more about how to integrate steps into your Pipeline in the Steps section of the Pipeline Syntax page.

For a list of other such plugins, see the Pipeline Steps Reference page.

Publish Over SSH

step([$class: 'BapSshPromotionPublisherPlugin']): Send build artifacts over SSH

Send files or execute commands over SSH as a build step during a promotion process.
  • publishers
      Array / List of Nested Object
    • configName

      Select an SSH configuration from the list configured in the global configuration of this Jenkins.

      The configuration defines the connection properties and base directory of the SSH server.

      • Type: String
    • verbose
      Select to enable an obscene amount of information to the Jenkins console - only really useful to help track down problems.
      • Type: boolean
    • transfers
        Array / List of Nested Object
      • sourceFiles

        Files to upload to a server.

        The string is a comma separated list of includes for an Ant fileset eg. '**/*.jar' (see Patterns in the Ant manual).
        The base directory for this fileset is the workspace.

        • Type: String
      • excludes

        Exclude files from the Transfer set.

        The string is a comma separated list of excludes for an Ant fileset eg. '**/*.log,**/*.tmp,.git/' (see Patterns in the Ant manual)

        • Type: String
      • remoteDirectory

        Optional destination folder.

        This folder will be below the one in the global configuration, if present.
        The folder will be created if does not exist.

        • Type: String
      • removePrefix

        First part of the file path that should not be created on the remote server.

        Directory structures are created relative to the base directory, which is usually the workspace.
        You normally do not want the full path to these files to be created on the server.
        For example if Source files were target/deployment/images/**/ then you may want Remove prefix to be target/deployment This would create the images folder under the remote directory, and not target/deployment
        Jenkins environment variables can be used in this path.

        If you use remove prefix, then ALL source file paths MUST start with the prefix.

        • Type: String
      • remoteDirectorySDF

        Select this to include the timestamp in the remote directory.

        The timestamp is the date of build. If this publisher is being used during a promotion, then the timestamp is that of the build that is being promoted.
        This setting turns the remote directory option into a java SimpleDateFormat.
        The SimpleDateFormat(SDF) uses letters to represent components of the date, like the month, year, or day of the week. Click here for more information about the date patterns.
        As the SDF reserves all of the letters [A-Z][a-z], any that you want to appear literally in the directory that is created will need to be quoted.

        Some examples follow - all examples are based on a build with a timestamp of 3:45 pm and 55 seconds on the 7th November 2010.

        Remote directory Directories created
        'qa-approved/'yyyyMMddHHmmss qa-approved/20101107154555
        'builds/'yyyy/MM/dd/'build-${BUILD_NUMBER}' builds/2010/11/07/build-456 (if the build was number 456)
        yyyy_MM/'build'-EEE-d-HHmmss 2010_11/build-Sun-7-154555
        yyyy-MM-dd_HH-mm-ss 2010-11-07_15-45-55

        • Type: boolean
      • flatten

        Only create files on the server, don't create directories (except for the remote directory, if present).

        All files that have been selected to transfer must have unique filenames. The publisher will stop and fail as soon as a duplicate filename is found when using the flatten option.

        • Type: boolean
      • cleanRemote
        • Type: boolean
      • noDefaultExcludes
        • Type: boolean
      • makeEmptyDirs

        The default behaviour of this plugin is to match files, and then create any directories required to preserve the paths to the files.
        Selecting this option will create any directories that match the Source files pattern, even if empty.

        • Type: boolean
      • patternSeparator

        The regular expression that is used to separate the Source files and Exclude files patterns.

        The Source files and Exclude files both accept multiple patterns that by default are split using

        [, ]+
        which is how Ant, by default, handles multiple patterns in a single string.

        The above expression makes it difficult to reference files or directories that contain spaces. This option allows the expression to be set to something that will preserve the spaces in a pattern eg. a single comma.

        • Type: String
      • execCommand (optional)

        A command to execute on the remote server.

        This command will be executed on the remote server after any files are transferred.
        The SSH Transfer Set must include either a Source Files pattern, an Exec command, or both. If both are present, the files are transferred before the command is executed. If you want to Exec before the files are transferred, use 2 Transfer Sets and move the Exec command before the Transfer set that includes a Source files pattern.

        • Type: String
      • execTimeout (optional)

        Timeout in milliseconds for the Exec command.

        Set to zero to disable.

        • Type: int
      • usePty (optional)

        Exec the command in a pseudo tty.

        This will enable the execution of sudo commands that require a tty (and possibly help in other scenarios too.)
        From the sudoers(5) man page:

        requiretty      If set, sudo will only run when the user is logged in
                        to a real tty.  When this flag is set, sudo can only be
                        run from a login session and not via other means such
                        as cron(8) or cgi-bin scripts.  This flag is off by
                        default.
            

        • Type: boolean
      • useAgentForwarding (optional)

        Exec the command using Agent Forwarding.

        Allows a chain of ssh connections to forward key challenges back to the original agent, thus eliminating the need for using a password or public/private keys for these connections.

        From the ssh(1) man page:

                Enables forwarding of the authentication agent connection.  This can also be specified on a per-host basis in a configuration file.
        
                Agent forwarding should be enabled with caution.  Users with the ability to bypass file permissions on the remote host (for the agent's UNIX-domain socket) can access the local agent through the forwarded connection.
                An attacker cannot obtain key material from the agent, however they can perform operations on the keys that enable them to authenticate using the identities loaded into the agent.
            
        • Type: boolean
      • useSftpForExec (optional)

        Using SFTP protocol instead of SSH for Exec command.

        Supported commands: mkdir, ln, symlink, rm, rmdir, cd, get, ls

        • Type: boolean
    • useWorkspaceInPromotion

      Set the root directory for the Source files to the workspace.

      By default this plugin uses the artifacts directory (where archived artifacts are stored). This allows the artifacts from the build number that you are promoting to be sent somewhere else.

      If you run tasks that produce files in the workspace during the promotion and you want to publish them, then set this option.

      If you need to send files from both the workspace and the archive directory, then you need to add a second server, even if you want to send the files to the same place. This is due to the fact that the workspace is not necessarily on the same host as the archive directory.

      • Type: boolean
    • usePromotionTimestamp

      Use the build time of the promotion when the remote directory is a date format.

      By default this plugin uses the time of the original build (the one that is being promoted) when formatting the remote directory. Setting this option will mean that if you use the remote directory is a date format option, it will use the time that the promotion process runs, instead of the original build.

      • Type: boolean
    • sshRetry

      If publishing to this server or command execution fails, try again.

      Files that were successfully transferred will not be re-sent.
      If Exec command is configured, but fails in any way (including a non zero exit code), then it will be retried.

        Nested Object
      • retries
        The number of times to retry this server in the event of failure.
        • Type: int
      • retryDelay
        The time to wait, in milliseconds, before attempting another transfer.
        • Type: long
    • sshLabel

      Set the label for this Server instance - for use with Parameterized publishing.

      Expand the help for Parameterized publishing for more details.

        Nested Object
      • label

        Set the label for this Server instance - for use with Parameterized publishing.

        Expand the help for Parameterized publishing for more details.

        • Type: String
    • sshCredentials
      Set the credentials to use with this connection.

      If you want to use different credentials from those configured for this server, or if the credentials have not been specified for this server, then enable this option and set them here.

        Nested Object
      • username
        The username to connect with.
        • Type: String
      • encryptedPassphrase
        The passphrase for the private key, or the password for password authentication if no Key or Path to key is configured.
        Leave blank if the key is not encrypted.
        • Type: String
      • key

        The private key.

        Paste the private key here, or provide the path to the file containing the key in Path to key.

        • Type: String
      • keyPath

        The path to the private key.

        Either supply the path to the file containing the key, or paste the key into the Key box.
        The Path to key can be absolute, or relative to $JENKINS_HOME

        • Type: String
  • continueOnError
    • Type: boolean
  • failOnError
    • Type: boolean
  • alwaysPublishFromMaster
    • Type: boolean
  • masterNodeName
    • Type: String
  • paramPublish
      Nested Object
    • parameterName
      The name of the parameter or environment variable that will contain the expression for matching the labels.
      • Type: String

sshPublisher: Send build artifacts over SSH

Send files or execute commands over SSH.
  • alwaysPublishFromMaster (optional)

    Select to publish from the Jenkins master.

    The default is to publish from the server that holds the files to transfer (workspace on the agent, or artifacts directory on the master).
    Enabling this option could help dealing with strict network configurations and firewall rules.
    This option will cause the files to be transferred through the master before being sent to the remote server, this may increase network traffic, and could increase the build time.

    • Type: boolean
  • continueOnError (optional)
    Select to continue publishing to the other servers after a problem with a previous server.
    • Type: boolean
  • failOnError (optional)
    Select to mark the build as a failure if there is a problem publishing to a server. The default is to mark the build as unstable.
    • Type: boolean
  • masterNodeName (optional)

    Set the NODE_NAME for the master Jenkins.

    Set this option to give a value to the NODE_NAME environment variable when the value is missing (the Jenkins master).
    This is useful if you use the NODE_NAME variable in the remote directory option and the build may occur on the master.

    • Type: String
  • paramPublish (optional)
      Nested Object
    • parameterName
      The name of the parameter or environment variable that will contain the expression for matching the labels.
      • Type: String
  • publishers (optional)
      Array / List of Nested Object
    • configName

      Select an SSH configuration from the list configured in the global configuration of this Jenkins.

      The configuration defines the connection properties and base directory of the SSH server.

      • Type: String
    • verbose
      Select to enable an obscene amount of information to the Jenkins console - only really useful to help track down problems.
      • Type: boolean
    • transfers
        Array / List of Nested Object
      • sourceFiles

        Files to upload to a server.

        The string is a comma separated list of includes for an Ant fileset eg. '**/*.jar' (see Patterns in the Ant manual).
        The base directory for this fileset is the workspace.

        • Type: String
      • excludes

        Exclude files from the Transfer set.

        The string is a comma separated list of excludes for an Ant fileset eg. '**/*.log,**/*.tmp,.git/' (see Patterns in the Ant manual)

        • Type: String
      • remoteDirectory

        Optional destination folder.

        This folder will be below the one in the global configuration, if present.
        The folder will be created if does not exist.

        • Type: String
      • removePrefix

        First part of the file path that should not be created on the remote server.

        Directory structures are created relative to the base directory, which is usually the workspace.
        You normally do not want the full path to these files to be created on the server.
        For example if Source files were target/deployment/images/**/ then you may want Remove prefix to be target/deployment This would create the images folder under the remote directory, and not target/deployment
        Jenkins environment variables can be used in this path.

        If you use remove prefix, then ALL source file paths MUST start with the prefix.

        • Type: String
      • remoteDirectorySDF

        Select this to include the timestamp in the remote directory.

        The timestamp is the date of build. If this publisher is being used during a promotion, then the timestamp is that of the build that is being promoted.
        This setting turns the remote directory option into a java SimpleDateFormat.
        The SimpleDateFormat(SDF) uses letters to represent components of the date, like the month, year, or day of the week. Click here for more information about the date patterns.
        As the SDF reserves all of the letters [A-Z][a-z], any that you want to appear literally in the directory that is created will need to be quoted.

        Some examples follow - all examples are based on a build with a timestamp of 3:45 pm and 55 seconds on the 7th November 2010.

        Remote directory Directories created
        'qa-approved/'yyyyMMddHHmmss qa-approved/20101107154555
        'builds/'yyyy/MM/dd/'build-${BUILD_NUMBER}' builds/2010/11/07/build-456 (if the build was number 456)
        yyyy_MM/'build'-EEE-d-HHmmss 2010_11/build-Sun-7-154555
        yyyy-MM-dd_HH-mm-ss 2010-11-07_15-45-55

        • Type: boolean
      • flatten

        Only create files on the server, don't create directories (except for the remote directory, if present).

        All files that have been selected to transfer must have unique filenames. The publisher will stop and fail as soon as a duplicate filename is found when using the flatten option.

        • Type: boolean
      • cleanRemote
        • Type: boolean
      • noDefaultExcludes
        • Type: boolean
      • makeEmptyDirs

        The default behaviour of this plugin is to match files, and then create any directories required to preserve the paths to the files.
        Selecting this option will create any directories that match the Source files pattern, even if empty.

        • Type: boolean
      • patternSeparator

        The regular expression that is used to separate the Source files and Exclude files patterns.

        The Source files and Exclude files both accept multiple patterns that by default are split using

        [, ]+
        which is how Ant, by default, handles multiple patterns in a single string.

        The above expression makes it difficult to reference files or directories that contain spaces. This option allows the expression to be set to something that will preserve the spaces in a pattern eg. a single comma.

        • Type: String
      • execCommand (optional)

        A command to execute on the remote server.

        This command will be executed on the remote server after any files are transferred.
        The SSH Transfer Set must include either a Source Files pattern, an Exec command, or both. If both are present, the files are transferred before the command is executed. If you want to Exec before the files are transferred, use 2 Transfer Sets and move the Exec command before the Transfer set that includes a Source files pattern.

        • Type: String
      • execTimeout (optional)

        Timeout in milliseconds for the Exec command.

        Set to zero to disable.

        • Type: int
      • usePty (optional)

        Exec the command in a pseudo tty.

        This will enable the execution of sudo commands that require a tty (and possibly help in other scenarios too.)
        From the sudoers(5) man page:

        requiretty      If set, sudo will only run when the user is logged in
                        to a real tty.  When this flag is set, sudo can only be
                        run from a login session and not via other means such
                        as cron(8) or cgi-bin scripts.  This flag is off by
                        default.
            

        • Type: boolean
      • useAgentForwarding (optional)

        Exec the command using Agent Forwarding.

        Allows a chain of ssh connections to forward key challenges back to the original agent, thus eliminating the need for using a password or public/private keys for these connections.

        From the ssh(1) man page:

                Enables forwarding of the authentication agent connection.  This can also be specified on a per-host basis in a configuration file.
        
                Agent forwarding should be enabled with caution.  Users with the ability to bypass file permissions on the remote host (for the agent's UNIX-domain socket) can access the local agent through the forwarded connection.
                An attacker cannot obtain key material from the agent, however they can perform operations on the keys that enable them to authenticate using the identities loaded into the agent.
            
        • Type: boolean
      • useSftpForExec (optional)

        Using SFTP protocol instead of SSH for Exec command.

        Supported commands: mkdir, ln, symlink, rm, rmdir, cd, get, ls

        • Type: boolean
    • useWorkspaceInPromotion

      Set the root directory for the Source files to the workspace.

      By default this plugin uses the artifacts directory (where archived artifacts are stored). This allows the artifacts from the build number that you are promoting to be sent somewhere else.

      If you run tasks that produce files in the workspace during the promotion and you want to publish them, then set this option.

      If you need to send files from both the workspace and the archive directory, then you need to add a second server, even if you want to send the files to the same place. This is due to the fact that the workspace is not necessarily on the same host as the archive directory.

      • Type: boolean
    • usePromotionTimestamp

      Use the build time of the promotion when the remote directory is a date format.

      By default this plugin uses the time of the original build (the one that is being promoted) when formatting the remote directory. Setting this option will mean that if you use the remote directory is a date format option, it will use the time that the promotion process runs, instead of the original build.

      • Type: boolean
    • sshRetry

      If publishing to this server or command execution fails, try again.

      Files that were successfully transferred will not be re-sent.
      If Exec command is configured, but fails in any way (including a non zero exit code), then it will be retried.

        Nested Object
      • retries
        The number of times to retry this server in the event of failure.
        • Type: int
      • retryDelay
        The time to wait, in milliseconds, before attempting another transfer.
        • Type: long
    • sshLabel

      Set the label for this Server instance - for use with Parameterized publishing.

      Expand the help for Parameterized publishing for more details.

        Nested Object
      • label

        Set the label for this Server instance - for use with Parameterized publishing.

        Expand the help for Parameterized publishing for more details.

        • Type: String
    • sshCredentials
      Set the credentials to use with this connection.

      If you want to use different credentials from those configured for this server, or if the credentials have not been specified for this server, then enable this option and set them here.

        Nested Object
      • username
        The username to connect with.
        • Type: String
      • encryptedPassphrase
        The passphrase for the private key, or the password for password authentication if no Key or Path to key is configured.
        Leave blank if the key is not encrypted.
        • Type: String
      • key

        The private key.

        Paste the private key here, or provide the path to the file containing the key in Path to key.

        • Type: String
      • keyPath

        The path to the private key.

        Either supply the path to the file containing the key, or paste the key into the Key box.
        The Path to key can be absolute, or relative to $JENKINS_HOME

        • Type: String

Was this page helpful?

Please submit your feedback about this page through this quick form.

Alternatively, if you don't wish to complete the quick form, you can simply indicate if you found this page helpful?

    


See existing feedback here.