SSHExec
An SSH Exec build step.
Example. Adds an SSH Exec build step with custom port and Uploaded key authentication method.
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
sshExec {
name = "My SSH Exec build step"
commands = """
command1
command2
""".trimIndent()
targetUrl = "8.8.8.8"
port = 2222
authMethod = uploadedKey {
username = "username"
passphrase = "credentialsJSON:******"
key = "id_rsa"
}
}
Content copied to clipboard }
}
Example. Adds an SSH Exec build step with Default private key authentication method.
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
sshExec {
name = "My SSH Exec build step"
commands = """
command1
command2
""".trimIndent()
targetUrl = "8.8.8.8"
authMethod = defaultPrivateKey {
username = "username"
passphrase = "credentialsJSON:******"
}
}
Content copied to clipboard }
}
Example. Adds an SSH Exec build step with pty enabled and Custom private key authentication method.
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
sshExec {
name = "My SSH Exec build step"
pty = "vt100"
commands = """
command1
command2
""".trimIndent()
targetUrl = "8.8.8.8"
authMethod = customPrivateKey {
keyFile = "path/to/key/file"
username = "username"
passphrase = "credentialsJSON:******"
}
}
Content copied to clipboard }
}
Example. Adds an SSH Exec build step with Password authentication method.
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
sshExec {
name = "My SSH Exec build step"
commands = """
command1
command2
""".trimIndent()
targetUrl = "8.8.8.8"
authMethod = password {
username = "username"
password = "credentialsJSON:******"
}
}
Content copied to clipboard }
}
Example. Adds an SSH Exec build step with SSH-Agent authentication method. This build step will run even if some previous build steps are failed.
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
sshExec {
name = "My SSH Exec build step"
executionMode = BuildStep.ExecutionMode.RUN_ON_FAILURE
commands = """
command1
command2
""".trimIndent()
targetUrl = "8.8.8.8"
authMethod = sshAgent {
username = "username"
}
}
Content copied to clipboard }
}
See also
Properties
An SSH authentication method.
Optional collection of build step execution conditions
Build step execution mode
Functions
Deletes all configured build step conditions
Configures build step conditions
Copies parameters of this object to the specified target
Will try to perform private key authentication using the given public key file with given passphrase.
Will try to perform private key authentication using the ~/.ssh/config settings. If no settings file exists, will try to use the ~/.ssh/rsa_pub public key file.
Simple password authentication.
Use ssh-agent for authentication, the SSH-Agent build feature must be enabled.
Uses the key(s) uploaded to the project.
Validates this object and reports found errors to the provided consumer