• Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • ssh-steps-plugin
    • None

      Currently we need to use

      withCredentials
      

      to map the credentials to all the steps, it would nice to have credentials store integrated to read the credentials from store. 

          [JENKINS-55817] Support Credentials store for SSH Steps

          Aleksandr added a comment -

          Had the same issue. As a workaround, I'd created a function like:

          def login(String ip, skey) {
            remote=[:]
            remote.name='the remote server'
            remote.host="${ip}"
            remote.user='jenkins'
            remote.allowAnyHosts = true
            remote.identityFile="{skey}"
            return remote
          }

          Set the environment variables:

              environment {
                  SSH_HOST1=credentials('host1')
                  SSH_HOST2=credentials('host2')
              } 

          And then used the function in the steps with corresponding values like:

                  stage('Test') {
                      steps {
                          login('10.0.51.145', env.SSH_HOST1)
                          sshCommand remote: remote, command: "ip a"
                      } 

          Works fine for me.

           

           

          Aleksandr added a comment - Had the same issue. As a workaround, I'd created a function like: def login( String ip, skey) {   remote=[:]   remote.name= 'the remote server'   remote.host= "${ip}"   remote.user= 'jenkins'   remote.allowAnyHosts = true   remote.identityFile= "{skey}"   return remote } Set the environment variables:   environment {         SSH_HOST1=credentials( 'host1' )       SSH_HOST2=credentials( 'host2' )     } And then used the function in the steps with corresponding values like:       stage( 'Test' ) {             steps {                 login( '10.0.51.145' , env.SSH_HOST1)                 sshCommand remote: remote, command: "ip a"             } Works fine for me.    

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

              Created:
              Updated: