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

Declarative pipeline with ssh-steps-plugin

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • ssh-steps-plugin
    • None
    • Jenkins (version 2.150.2)
      ssh steps plugin (version 1.2.1)

       

      Hello,

      This is a question more than a bug report.

      I'd like to use ssh private key account (with passphrase) from Jenkins credentials store.

      I did successfully used this plugin with an ssh key pair in a scripted pipeline using the provided code sample below

      https://github.com/jenkinsci/ssh-steps-plugin#withcredentials

      My groovy code looks like this

      def remote = [:]
      remote.name = "hostname"
      remote.host = "hostname"
      remote.allowAnyHosts = true
      node {
        withCredentials([sshUserPrivateKey(credentialsId: 'xxxxx-xxxxx-xxxx', keyFileVariable: 'identity', passphraseVariable: 'passphrase', usernameVariable: 'userName')]) {
        remote.user = userName
          remote.identityFile = identity
        remote.passphrase = passphrase
        stage("SSH Steps Rocks!") {
          writeFile file: 'abc.sh', text: 'ls'
          sshPut remote: remote, from: 'abc.sh', into: '.'
        }
      }

      I've tried in several way to use Declarative Pipeline but without success.

      Do you have any tips or samples to share ?

      Thanks for your help.

      Davide

            nrayapati Naresh Rayapati
            df15kb Davide F
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: