This step provides an easy way to transfer files via SCP.
This step is using the sshAgentWrapper
to wrap
the shell command.
So if you configured the ssh credentials then the key is automatically provided.
You don't have to take care about path escaping! This step uses the
ScpCommandBuilderImpl
which used the
ShellUtils
to escape the paths for you.
(SCP) : [
(SCP_HOST) : "somehost",
(SCP_RECURSIVE) : true,
(SCP_SOURCE) : "path to source/*",
(SCP_DESTINATION): "/var/www/target path with spaces/",
]
Will be escaped into
SCP_SOURCE
=path\ to\ source/*
SCP_DESTINATION
=/var/www/target\ path\ with\ spaces/
import static io.wcm.devops.jenkins.pipeline.utils.ConfigConstants.*
Map config = [
// configure scp transport
(SCP) : [
(SCP_HOST) : "your-target-host",
(SCP_SOURCE) : "target/index.html",
(SCP_DESTINATION): "/var/www/your-target-folder/",
]
]
transferScp(config)
import static io.wcm.devops.jenkins.pipeline.utils.ConfigConstants.*
Map config = [
// configure scp transport
(SCP) : [
(SCP_HOST) : "your-target-host",
(SCP_RECURSIVE) : true,
(SCP_SOURCE) : "target/*",
(SCP_DESTINATION): "/var/www/your-target-folder/",
]
]
transferScp(config)
Complete list of all configuration options.
All configuration options must be inside the scp
(ConfigConstants.SCP
) map element to be
evaluated and used by the step.
The scp
element must be a Map
.
import static io.wcm.devops.jenkins.pipeline.utils.ConfigConstants.*
transferScp([
(SCP): [
[
(SCP_ARGUMENTS): [],
(SCP_DESTINATION): '/path/to/target/dir-or-file',
(SCP_EXECUTABLE): 'scp',
(SCP_HOST): 'scp-target-host',
(SCP_HOST_KEY_CHECK): false,
(SCP_PORT): 22,
(SCP_RECURSIVE): true,
(SCP_SOURCE): '/path/to/source/dir-or-file',
(SCP_USER): "scp-user",
],
// more tool definitions
]
])
Constant | ConfigConstants.SCP_ARGUMENTS |
Type | List of String |
Default | [] |
Additional arguments for SCP like -v
for verbose output.
(SCP_ARGUMENTS): [ "-v" ]
Constant | ConfigConstants.SCP_DESTINATION |
Type | String |
Default | null |
Constant | ConfigConstants.SCP_EXECUTABLE |
Type | String |
Default | scp |
Defines the executable to use. Per default transferScp
expects the executable scp
to be in the PATH
Constant | ConfigConstants.SCP_HOST |
Type | String |
Default | null |
The scp destination host.
Constant | ConfigConstants.SCP_HOST_KEY_CHECK |
Type | Boolean |
Default | false |
Controls the host key check behavior. Per default the host key checking is disabled.
When set to false
(default) ssh arguments are automatically added to the command line.
-o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"
Constant | ConfigConstants.SCP_PORT |
Type | Integer |
Default | 22 |
Constant | ConfigConstants.SCP_RECURSIVE |
Type | Boolean |
Default | false |
When set to true the -r
argument is added to the command line and SCP will transfer in recursive mode.
Constant | ConfigConstants.SCP_SOURCE |
Type | String |
Default | null |
Path to the source which should be transferred.
Constant | ConfigConstants.SCP_USER |
Type | String |
Default | null |
The name of the user to use. Per default the user is determined during SSH credential auto lookup.