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

workflow-scm-step plugin does not find global credentials

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Critical Critical
    • None
    • Running on Jenkins ver. 2.176.2
      Credentials plugin: 2.2.1
      Credentials binding plugin: 1.19
      workflow-scm-step: 2.9

      OS: Ubuntu, 18.04.2 LTS (Bionic Beaver)

      Issue: fails to retrieve global credential and thus fails SCM step

      Description:

      When executing the pipeline or using the snippet generator tool, global credentials are not found and thus the SCM steps fail. Credentials can be created from the dropdown provided for the SCM step at the pipeline snippet generator, but are later not listed in the same dropdown, though visible in the global credentials page.

      We verified that credentials can be accessed in the pipeline using the command withCredentials(id).

      Code statement:

      checkout([$class: 'GitSCM', branches: [[name: '*/master']], userRemoteConfigs: [[credentialsId: 'github-secret', url: 'git@github.com:something/reponame.git']]])

      Execution output:
      15:15:00 Warning: CredentialId "github-secret" could not be found.15:15:00 Cloning the remote Git repository

          [JENKINS-58827] workflow-scm-step plugin does not find global credentials

          Ryan Leonard added a comment -

          I'm seeing a similar behavior appear in an Organization Folder (Bitbucket Branch Source Plugin). The Scan operation works fine, then the multibranch pipeline within fails with "Warning: CredentialID "github_api" could not be found"

          I am not savvy enough to know if this is actually the same issue, or if I should submit a separate Jenkins issue for that plugin.

          Ryan Leonard added a comment - I'm seeing a similar behavior appear in an Organization Folder ( Bitbucket Branch Source Plugin ). The Scan operation works fine, then the multibranch pipeline within fails with "Warning: CredentialID "github_api" could not be found" I am not savvy enough to know if this is actually the same issue, or if I should submit a separate Jenkins issue for that plugin.

          Andrei Audzei added a comment - - edited

          Updated: there are some mistakes about token possibilities, but some way - it works...

          Second update: with "user-pass" creds for Bitbucket scanning, bug don't reproduced

          rleonar7 Today I got the same error. After few hours of investigation my problem has been "fixed". Maybe it will be helpful for you.
          If you use for Butbucket source scan operations credentials with "token" type - you can't use the same credentials for cloning repo, because scanning works through http-api (that available by "token" or "user-password" creds), and cloning repo can't use "token" creds - it can be done by "user-pass" creds, or by "ssh-key" creds (in this case you should use ssh repo path). So, I fix my problem by running checkout with scm configs from job settings, but replaced some params (creds and repo url to "ssh-style" in my case):

          checkout([$class: 'GitSCM',
              branches: [[name: "${scm.branches[0]}"]],
              userRemoteConfigs: [[url: STASH_PROJECT_REPO_SSH_URL, refspec: scm.userRemoteConfigs[0].refspec, credentialsId: 'ssh_stash_public_key']]]) 

          Andrei Audzei added a comment - - edited Updated: there are some mistakes about token possibilities, but some way - it works... Second update: with "user-pass" creds for Bitbucket scanning, bug don't reproduced rleonar7 Today I got the same error. After few hours of investigation my problem has been "fixed". Maybe it will be helpful for you. If you use for Butbucket source scan operations credentials with "token" type - you can't use the same credentials for cloning repo, because scanning works through http-api (that available by "token" or "user-password" creds), and cloning repo can't use "token" creds - it can be done by "user-pass" creds, or by "ssh-key" creds (in this case you should use ssh repo path). So, I fix my problem by running checkout with scm configs from job settings, but replaced some params (creds and repo url to "ssh-style" in my case): checkout([$class: 'GitSCM' , branches: [[name: "${scm.branches[0]}" ]], userRemoteConfigs: [[url: STASH_PROJECT_REPO_SSH_URL, refspec: scm.userRemoteConfigs[0].refspec, credentialsId: 'ssh_stash_public_key' ]]])

          Mark Waite added a comment -

          Duplicate of the git plugin issue that fails to report a helpful error message when an invalid but existing credential type is used.

          The git plugin supports two protocols and one credential type for each protocol.

          • HTTP/HTTPS protocol with username / password credential
          • SSH protocol with private key credential

          In this report, a username / password credential or a token credential are being used to access a repository with SSH protocol. The git plugin should report that the referenced credential exists but is the wrong type of credential for the requested protocol.

          Mark Waite added a comment - Duplicate of the git plugin issue that fails to report a helpful error message when an invalid but existing credential type is used. The git plugin supports two protocols and one credential type for each protocol. HTTP/HTTPS protocol with username / password credential SSH protocol with private key credential In this report, a username / password credential or a token credential are being used to access a repository with SSH protocol. The git plugin should report that the referenced credential exists but is the wrong type of credential for the requested protocol.

            Unassigned Unassigned
            jmrozanec Jose Martin Rozanec
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: