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

Git clone fails with JGit and SSH Credentials

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Component/s: git-client-plugin
    • Labels:
    • Environment:
      Linux/Debian
      Jenkins 1.533
      git-client-plugin 1.3.0
      git-plugin 2.0-beta2
      scm-api-plugin 0.2
    • Similar Issues:

      Description

      Hi,

      I've tried to switch to the next (unreleased) version of the Git plugin, in order to integrate with Jenkins credentials repository.

      I've selected:

      • Repository: git@github.com:ORG/PROJECT.git
      • Credentials: <A ssh deploy key linked to that project>
      • Git executable: JGit
      • Activate SSH Agent with the same credentials

      The SSH key isn't set as the "default key" of the Jenkins shell user on the server.

      As a result, Git SCM Polling, Github web hook and pre-build fetch fail.
      When I switch back to the "native" git executable, polling and web hook fail (as usual), but pre-build fetch succeed.

      Here is the stack trace I get:

      Started by user anonymous
      Building remotely on kiso3 in workspace /home/jenkins/workspace/blusers
      [ssh-agent] Using credentials git (blusers)
      [ssh-agent] Looking for ssh-agent implementation...
      [ssh-agent]   Java/JNR ssh-agent
      [ssh-agent] Started.
      Fetching changes from the remote Git repository
      FATAL: Cannot open session, connection is not authenticated.
      java.lang.IllegalStateException: Cannot open session, connection is not authenticated.
      	at com.trilead.ssh2.Connection.openSession(Connection.java:1102)
      	at org.jenkinsci.plugins.gitclient.trilead.TrileadSession.exec(TrileadSession.java:24)
      	at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248)
      	at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147)
      	at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136)
      	at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122)
      	at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1105)
      	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:128)
      	at org.jenkinsci.plugins.gitclient.JGitAPIImpl.fetch(JGitAPIImpl.java:342)
      	at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:616)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:299)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:280)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:239)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:118)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      	at hudson.remoting.Request$2.run(Request.java:326)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:679)
      

        Attachments

          Issue Links

            Activity

            Hide
            dc00 D Claus added a comment -

            Other people (http://stackoverflow.com/questions/34317581/jenkins-workflow-multibranch-with-git-illegalstateexception) including me, are having this same problem.

            I am using Jenkins 2.7 with the multibranch plugin, all plugins are at the latest version.

            If I create a project, and add a "Branch Source" of "Git", type in the repository (git@git.DOMAIN.com:/opt/git/PROJECT.git), select credentials that work everywhere else in Jenkins, and click "Save" I get a "Branch Indexing Log" screen with this stack trace:

            Started
            Setting origin to git@git.(DOMAIN).com:/opt/git/(PROJECT).git
            Fetching origin...
            FATAL: Failed to recompute children of deleteme multibranch
            java.lang.IllegalStateException: Cannot open session, connection is not authenticated.
            	at com.trilead.ssh2.Connection.openSession(Connection.java:1127)
            	at org.jenkinsci.plugins.gitclient.trilead.TrileadSession.exec(TrileadSession.java:32)
            	at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:262)
            	at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:161)
            	at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136)
            	at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122)
            	at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1138)
            	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:130)
            	at org.jenkinsci.plugins.gitclient.JGitAPIImpl.fetch(JGitAPIImpl.java:678)
            	at jenkins.plugins.git.AbstractGitSCMSource.retrieve(AbstractGitSCMSource.java:174)
            	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:146)
            	at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:296)
            	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:157)
            	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:122)
            	at hudson.model.ResourceController.execute(ResourceController.java:98)
            	at hudson.model.Executor.run(Executor.java:410)
            Finished: FAILURE
            
            Show
            dc00 D Claus added a comment - Other people ( http://stackoverflow.com/questions/34317581/jenkins-workflow-multibranch-with-git-illegalstateexception ) including me, are having this same problem. I am using Jenkins 2.7 with the multibranch plugin, all plugins are at the latest version. If I create a project, and add a "Branch Source" of "Git", type in the repository (git@git.DOMAIN.com:/opt/git/PROJECT.git), select credentials that work everywhere else in Jenkins, and click "Save" I get a "Branch Indexing Log" screen with this stack trace: Started Setting origin to git@git.(DOMAIN).com:/opt/git/(PROJECT).git Fetching origin... FATAL: Failed to recompute children of deleteme multibranch java.lang.IllegalStateException: Cannot open session, connection is not authenticated. at com.trilead.ssh2.Connection.openSession(Connection.java:1127) at org.jenkinsci.plugins.gitclient.trilead.TrileadSession.exec(TrileadSession.java:32) at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:262) at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:161) at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136) at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122) at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1138) at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:130) at org.jenkinsci.plugins.gitclient.JGitAPIImpl.fetch(JGitAPIImpl.java:678) at jenkins.plugins.git.AbstractGitSCMSource.retrieve(AbstractGitSCMSource.java:174) at jenkins.scm.api.SCMSource.fetch(SCMSource.java:146) at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:296) at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:157) at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:122) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:410) Finished: FAILURE
            Hide
            markewaite Mark Waite added a comment -

            D Claus please open a separate bug report for that problem. It sounds like it is specific to the multi-branch plugin rather than the git plugin or the git client plugin.

            Show
            markewaite Mark Waite added a comment - D Claus please open a separate bug report for that problem. It sounds like it is specific to the multi-branch plugin rather than the git plugin or the git client plugin.
            Hide
            dc00 D Claus added a comment -

            Looks like the actual bug is JENKINS-33983. The workaround (also posted in that JIRA) is to go into "Manage Jenkins" -> "Global Tool Configuration" then under "Git" click "Add Git" then select "JGit". See also https://wiki.jenkins-ci.org/display/JENKINS/Git+plugin+2.0+beta+testing#Gitplugin2.0betatesting-ActivatingJGit.
            The attached links says "go to the system configuration page" which should read "go into the Global Tool Configuration page".

            Show
            dc00 D Claus added a comment - Looks like the actual bug is JENKINS-33983 . The workaround (also posted in that JIRA) is to go into "Manage Jenkins" -> "Global Tool Configuration" then under "Git" click "Add Git" then select "JGit". See also https://wiki.jenkins-ci.org/display/JENKINS/Git+plugin+2.0+beta+testing#Gitplugin2.0betatesting-ActivatingJGit . The attached links says "go to the system configuration page" which should read "go into the Global Tool Configuration page".
            Hide
            ptho ptho ho added a comment -

            I run into the same issue. Pipeline works but Multibranch Pipeline job doesn't work . Add JGit to under GIT in Global Tool Configuration as well, it's not working.

            Setting origin to git@github.somecompany.com:RnD/test.git
            Fetching origin...
            FATAL: Failed to recompute children of test_multibranch_pipeline
            java.lang.IllegalStateException: Cannot open session, connection is not authenticated.

            I tried different credentials, none worked in multibranch pipeline.

            Show
            ptho ptho ho added a comment - I run into the same issue. Pipeline works but Multibranch Pipeline job doesn't work . Add JGit to under GIT in Global Tool Configuration as well, it's not working. Setting origin to git@github.somecompany.com:RnD/test.git Fetching origin... FATAL: Failed to recompute children of test_multibranch_pipeline java.lang.IllegalStateException: Cannot open session, connection is not authenticated. I tried different credentials, none worked in multibranch pipeline.
            Hide
            markewaite Mark Waite added a comment -

            Refer to JENKINS-36958 for the bug which tracks one case where a multi-branch pipeline cannot authenticate in the same environment where a freestyle job can authenticate. The distinction in that case is that the freestyle job uses command line git for its initial clone, while the multi-branch pipeline uses JGit

            Show
            markewaite Mark Waite added a comment - Refer to JENKINS-36958 for the bug which tracks one case where a multi-branch pipeline cannot authenticate in the same environment where a freestyle job can authenticate. The distinction in that case is that the freestyle job uses command line git for its initial clone, while the multi-branch pipeline uses JGit

              People

              • Assignee:
                kohsuke Kohsuke Kawaguchi
                Reporter:
                xelnor Raphaƫl Barrois
              • Votes:
                1 Vote for this issue
                Watchers:
                13 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: