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

          Code changed in jenkins
          User: R. Tyler Croy
          Path:
          Jenkinsfile
          http://jenkins-ci.org/commit/jenkins.io/ff3bc09b643da104c514798098a735f8fff591b3
          Log:
          Add support for deploying the built zip out to the beta site

          The following tickets were created as a result of this experimentation:

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: R. Tyler Croy Path: Jenkinsfile http://jenkins-ci.org/commit/jenkins.io/ff3bc09b643da104c514798098a735f8fff591b3 Log: Add support for deploying the built zip out to the beta site The following tickets were created as a result of this experimentation: JENKINS-32101 JENKINS-32102 JENKINS-32104

          Patrick Wolf added a comment -

          Is this two separate bugs rtyler?

          • the snippet generator inputs the id instead of the name
          • Using the credentials name fails .

          Do you know if this limited to the SSH-Agent plugin?

          Patrick Wolf added a comment - Is this two separate bugs rtyler ? the snippet generator inputs the id instead of the name Using the credentials name fails . Do you know if this limited to the SSH-Agent plugin?

          R. Tyler Croy added a comment -

          hrmpw I suppose you could interpret that as two bugs, The snippet generator is not performing the false behavior, since that's the only way to make the sshagent() step work, so I'm not sure I would consider that a bug.

          R. Tyler Croy added a comment - hrmpw I suppose you could interpret that as two bugs, The snippet generator is not performing the false behavior, since that's the only way to make the sshagent() step work, so I'm not sure I would consider that a bug.

          Jesse Glick added a comment -

          The step takes an ID. What help text are you referring to here? I am not following what you think the bug is.

          Jesse Glick added a comment - The step takes an ID. What help text are you referring to here? I am not following what you think the bug is.

          R. Tyler Croy added a comment -

          I believe this issue has since been fixed. The problem was at the time with the embedded "Add" credential dialogue and its inability to set the credential's ID properly.

          I can no longer reproduce this with Jenkins 2.7 and the following plugins:

          • Credentials Binding 1.7
          • Pipeline 2.1
          • SSH Agent 1.10

          R. Tyler Croy added a comment - I believe this issue has since been fixed. The problem was at the time with the embedded "Add" credential dialogue and its inability to set the credential's ID properly. I can no longer reproduce this with Jenkins 2.7 and the following plugins: Credentials Binding 1.7 Pipeline 2.1 SSH Agent 1.10

          Jesse Glick added a comment -

          malcorn whatever your issue is, it is probably unrelated to this issue.

          Jesse Glick added a comment - malcorn whatever your issue is, it is probably unrelated to this issue.

          Christopher Smith added a comment - - edited

          Not sure if this is the same as this bug, but I have a global credential with the name "deploy-staging" and ID "deploy-staging". When I attempt to reference this credential like so: `sshagent(credentials: ["deploy-staging"]) {` I get this error: "FATAL: [ssh-agent] Could not find specified credentials"

          If I leave the ID field blank when creating the credential and then reference the generated UUID instead, it works fine: `sshagent(credentials: ["f200deef-d09f-4237-9a15-03cc88033a68"]) {`

          Any update on this? Thanks!

          Christopher Smith added a comment - - edited Not sure if this is the same as this bug, but I have a global credential with the name "deploy-staging" and ID "deploy-staging". When I attempt to reference this credential like so: `sshagent(credentials: ["deploy-staging"] ) {` I get this error: "FATAL: [ssh-agent] Could not find specified credentials" If I leave the ID field blank when creating the credential and then reference the generated UUID instead, it works fine: `sshagent(credentials: ["f200deef-d09f-4237-9a15-03cc88033a68"] ) {` Any update on this? Thanks!

          I've just pulled the docker image today (docker run jenkinsci/blueocean).

          This is what I'm trying to do:

          node {
                  stage('ssh-step') {
                          sshagent (credentials: ['6baa8fe6-1728-41a2-b998-5c5b784af386']) {
                              sh 'ssh -o StrictHostKeyChecking=no -l username myhost'
          {{                }}}
          {{        }}}
          }

          in the errors I see:
          FATAL: [ssh-agent] Could not find specified credentials
           

          nicola limongi added a comment - I've just pulled the docker image today (docker run jenkinsci/blueocean ). This is what I'm trying to do: node {         stage('ssh-step') {                 sshagent (credentials: ['6baa8fe6-1728-41a2-b998-5c5b784af386'] ) {                     sh 'ssh -o StrictHostKeyChecking=no -l username myhost' {{                }}} {{        }}} } in the errors I see: FATAL: [ssh-agent] Could not find specified credentials  

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

              Created:
              Updated:
              Resolved: