Hello,
I have the following pipeline stage, which works great:
stage('Database') {
steps {
script {
remote = createDeployRemote()
withCredentials([
usernamePassword(credentialsId: "credential-id", usernameVariable: 'THE_USERNAME', passwordVariable: 'THE_PASSWORD')
]) {
sshCommand remote: remote,
command: """
somecommand \
--username="${THE_USERNAME}" \
--password="${THE_PASSWORD}"
"""
}
}
}
}
Jenkins complaints with the following warning:
I've changed my code to the following:
stage('Database') {
environment {
THE_CREDS = credentials("credential-id")
}
steps {
script {
remote = createDeployRemote()
sshCommand remote: remote,
command: """
printenv
somecommand \
--username="\$THE_CREDS_USR" \
--password="\$THE_CREDS_PSW"
"""
}
}
}
It seems that this plugin doesn't pass any of the environment variables to the remote machine.
I think there should be an option to pass all or some pre-defined environment variables to `sshCommand`.