Skip to main content

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



  • Pragnesh Patel

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

  • 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?

  • 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.

  • 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 and I think is not public available yet or something I'm not catching.

  • Denys Digtiar

    Hi Salvador,

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

  • Dawson Kumar

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

  • Beka61 Beka61


    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?


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.