Skip to main content

Fetch a userid and password from a Credential object in a Pipeline job.

Comments

7 comments

  • Pragnesh Patel

    How can i get User-Scoped Credentials (Personal Credentials) ?

    5
  • Salvador Salvador

    How can I get the username from a SSH Username with private key type credential? I was trying this:

    node {
    key = 'mySSHkey'
      stage('Test') {
        withCredentials([[$class: 'CertificateMultiBinding', credentialsId: key,
        keystoreVariable: 'keystore', aliasVariable: 'alias',
        passwordVariable: 'pass']]) {
          sh 'echo uname=$keystore alias=$alias pwd=$pass'
        }
      }

    }

     

    Jenkins complains with

     

    org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException: Credentials 'mySSHkey' is of type 'SSH Username with private key' where 'com.cloudbees.plugins.credentials.common.StandardCertificateCredentials' was expected

    Can you guide me about this?

    0
  • Denys Digtiar

    The error message tells you that Binding implementation that you have chosen, i.e., `CertificateMultiBinding`, is expecting the credential of type `StandardCertificateCredentials`, but you have supplied a credential of type 'SSH Username with private key'.

    Have you used Snippet Generator to get this pipeline code? If yes, then there might be a defect please raise it appropriately. If not, please use Snippet Generator to get the correct code.

    0
  • Salvador Salvador

    I didn't use the Snippet Generator because there is not such "snippet". So I tried to figure out how could be with using the post's examples but with a sshUserPrivateKey type.

    I've found this pull request on Credentials Binding plugin https://github.com/jenkinsci/credentials-binding-plugin/pull/18 and I think is not public available yet or something I'm not catching.

    1
  • Denys Digtiar

    Hi Salvador,

    As far as I can see from the Github changelog the feature was released in version 1.13

    0
  • Dawson Kumar

    @Salvador - Where you able to fix this issue? Facing the same problem.

    0
  • Beka61 Beka61

    hi,

    we use withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: '<CREDENTIAL_ID>', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']])

    but it fails when we use a credential configured on folder level instead of global scope.

    Found issue:

    Credential will be found, but the variable USERNAME contains the CREDENTIAL_ID instead of the username. The same credential configure globally works.

    How can I solve this?

    0

Please sign in to leave a comment.

About CloudBees Support

Our Support Engineers are available to help with any questions or problems you may have with any of our products.