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

Credentials must be referred to by ID which is Jenkins master specific

      The helptext is at odds with what gets generated by the Snippet Generator (see screenshot).

      node {
        sshagent (credentials: ['deploy-dev']) {
          sh 'ssh -o StrictHostKeyChecking=no -l cloudbees 192.168.1.106 uname -a'
        }
      }
      

      Multiple credentials could be passed in the array but it is not supported using Snippet Generator.

      This would be useful, since I have a staging and a production Jenkins master and I would like to refer to the credential by name instead of ID so I can use it between hosts. The snippet generated is with the ID, and only that will work it seems:

      sshagent(['05917262-0ebf-4491-bc84-5029e36ad0e8']) {
          // some block
      }
      

      If I attempt to use the credentials: ['foo'] syntax, my job will fail:

      FATAL: [ssh-agent] Could not find specified credentials
      [ssh-agent] Looking for ssh-agent implementation...
      [ssh-agent]   Java/JNR ssh-agent
      [ssh-agent] Started.
      

          [JENKINS-32101] Credentials must be referred to by ID which is Jenkins master specific

          R. Tyler Croy created issue -
          Jesse Glick made changes -
          Link New: This issue is related to JENKINS-32102 [ JENKINS-32102 ]
          R. Tyler Croy made changes -
          Resolution New: Cannot Reproduce [ 5 ]
          Status Original: Open [ 1 ] New: Closed [ 6 ]
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 167584 ] New: JNJira + In-Review [ 209548 ]
          Andrew Bayer made changes -
          Labels Original: workflow New: pipeline workflow
          Andrew Bayer made changes -
          Labels Original: pipeline workflow New: pipeline
          Matt A made changes -
          Resolution Original: Cannot Reproduce [ 5 ]
          Status Original: Closed [ 6 ] New: Reopened [ 4 ]
          Matt A made changes -
          Attachment New: creds.PNG [ 35011 ]
          Attachment New: pipeline_snippet_generator.PNG [ 35012 ]
          Jesse Glick made changes -
          Resolution New: Cannot Reproduce [ 5 ]
          Status Original: Reopened [ 4 ] New: Resolved [ 5 ]
          Matt A made changes -
          Comment [ I am having the same issue as described in this ticket. I'm sorry to reopen this issue if that's not the correct process.

          I've tried adding credentials in the Snippet Generator as well as through the main Jenkins Credential interface. No matter which way they are added, they don't appear to be available in the Pipeline.

          Pipeline: 2.4
          Jenkins: 2.19.2

          [Pipeline] sshagent
          FATAL: [ssh-agent] Could not find specified credentials
          [ssh-agent] Looking for ssh-agent implementation...
          [ssh-agent] Java/JNR ssh-agent
          [ssh-agent] Skipped registering BouncyCastle, not running on a remote agent
          [ssh-agent] Started.
          [Pipeline] {
          [Pipeline] sh
          [ssh-agent] Stopped.
          [ui] Running shell script
          + ssh -o StrictHostKeyChecking=no -l cloudui 10.x.x.x uname -a
          Permission denied, please try again.
          Permission denied, please try again.
          Permission denied (publickey,password).
          [Pipeline] }
          [Pipeline] // sshagent
          [Pipeline] }
          [Pipeline] // withEnv
          [Pipeline] }
          [Pipeline] // dir
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: script returned exit code 255 ]
          Matt A made changes -
          Attachment Original: pipeline_snippet_generator.PNG [ 35012 ]

            Unassigned Unassigned
            rtyler R. Tyler Croy
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: