Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-71654

ssh-steps-plugin does not allow to transfer ${WORKSPACE} with interpolation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • ssh-steps-plugin
    • 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

       

            nrayapati Naresh Rayapati
            round_table Vasya
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: