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

Multibranch: Git credentials are not used on checkout scm

XMLWordPrintable

      I've configured global credentials for SSH username and private key.

      They are used by a multibranch pipeline project to access a git repository.
      Indexing is working fine and the branch job is created.

      Started
       > git rev-parse --is-inside-work-tree # timeout=10
      Setting origin to ...Playground.git
       > git config remote.origin.url ...Playground.git # timeout=10
      Fetching & pruning origin...
      Fetching upstream changes from origin
       > git --version # timeout=10
      using GIT_SSH to set credentials Jenkins Private Key for Git Access
       > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/* --prune
      ...
      

      But the Branch Job itself is unable to access the repository:

      Branch indexing
       > git rev-parse --is-inside-work-tree # timeout=10
      Setting origin to ..Playground.git
       > git config remote.origin.url ..Playground.git # timeout=10
      Fetching origin...
      Fetching upstream changes from origin
       > git config --get remote.origin.url # timeout=10
      using GIT_SSH to set credentials Jenkins Private Key for Git Access
       > git fetch -t ..Playground.git +refs/heads/*:refs/remotes/origin/* # timeout=10
      Seen branch in repository origin/Test_Branch
      Seen branch in repository origin/development
      ...
      Seen 8 remote branches
      Cloning the remote Git repository
      Cloning repository ..Playground.git
       > git init /var/lib/jenkins/workspace/playground_development-FVZJG3FUP3I5HAUYK5DAE3QJUATGZYBRDFHXJH5R5ZSZMILHQWWQ@script # timeout=10
      Fetching upstream changes from ..Playground.git
       > git --version # timeout=10
      using GIT_SSH to set credentials Jenkins Private Key for Git Access
       > git fetch --tags --progress ..Playground.git +refs/heads/*:refs/remotes/origin/*
       > git config remote.origin.url ..Playground.git # timeout=10
       > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
       > git config remote.origin.url ..Playground.git # timeout=10
      Fetching upstream changes from ..Playground.git
      using GIT_SSH to set credentials Jenkins Private Key for Git Access
       > git fetch --tags --progress ..Playground.git +refs/heads/*:refs/remotes/origin/*
      Checking out Revision 41d170c75b56439500ee5e661a5c6f8787196427 (development)
       > git config core.sparsecheckout # timeout=10
       > git checkout -f 41d170c75b56439500ee5e661a5c6f8787196427
      First time build. Skipping changelog.
      [Pipeline] node
      Running on master in /var/lib/jenkins/workspace/playground_development-FVZJG3FUP3I5HAUYK5DAE3QJUATGZYBRDFHXJH5R5ZSZMILHQWWQ
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (preparation)
      [Pipeline] git
      Cloning the remote Git repository
      Cloning repository ..Playground.git
       > git init /var/lib/jenkins/workspace/playground_development-FVZJG3FUP3I5HAUYK5DAE3QJUATGZYBRDFHXJH5R5ZSZMILHQWWQ # timeout=10
      Fetching upstream changes from ..Playground.git
       > git --version # timeout=10
       > git fetch --tags --progress ..Playground.git +refs/heads/*:refs/remotes/origin/*
      ERROR: Error cloning remote repo 'origin'
      hudson.plugins.git.GitException: Command "git fetch --tags --progress ..Playground.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
      stdout: 
      stderr: Permission denied, please try again.
      Permission denied, please try again.
      Permission denied (publickey,password).
      fatal: Could not read from remote repository.
      
      Please make sure you have the correct access rights
      and the repository exists.
      
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1745)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1489)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:64)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:315)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:512)
      	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1042)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1082)
      	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:109)
      

      The current workaround is to put the keyfile in jenkins users ~/.ssh directory, but as of the documentation i think this must not be necessary.

      scm
      Represents the SCM configuration in a multibranch project build...

            mjdetullio Matthew DeTullio
            dageissl Daniel Geißler
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: