-
Bug
-
Resolution: Won't Fix
-
Major
-
None
After executing this code in Pipeline:
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins-ssh', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'userName')]) { def host host = [name: 'dev_new_wallets', host: "${variables.host_dev_mpb}", allowAnyHosts: true] host.user = userName host.identityFile = identity host.allowAnyHosts = true sshCommand remote: host, command: "systemctl stop ${repo}.service", sudo: true sshPut remote: host, from: "${WORKSPACE}", into: '/opt/company/' sshCommand remote: host, command: "/bin/npm run migrate --prefix /opt/company/${repo}", sudo: true sshCommand remote: host, command: "systemctl start ${repo}.service", sudo: true }
a warning about userName interpolation appears in the console:
Warning: A secret was passed to "sshPut" using Groovy String interpolation, which is insecure. Affected argument(s) used the following variable(s): [userName] See https://jenkins.io/redirect/groovy-string-interpolation for details.
If I insert a string instead of "${WORKSPACE}":
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins-ssh', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'userName')]) { def host host = [name: 'dev_new_wallets', host: "${variables.host_dev_mpb}", allowAnyHosts: true] host.user = userName host.identityFile = identity host.allowAnyHosts = true sshCommand remote: host, command: "systemctl stop ${repo}.service", sudo: true sshPut remote: host, from: '/home/jenkins/agent/workspace/Dev/NewWallets/mpb-copy', into: '/opt/company/' sshCommand remote: host, command: "/bin/npm run migrate --prefix /opt/company/${repo}", sudo: true sshCommand remote: host, command: "systemctl start ${repo}.service", sudo: true }
it works fine without warning