• Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • git-client-plugin
    • Linux/Debian
      Jenkins 1.533
      git-client-plugin 1.3.0
      git-plugin 2.0-beta2
      scm-api-plugin 0.2

      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)
      

          [JENKINS-19921] Git clone fails with JGit and SSH Credentials

          krzyk added a comment -

          markewaite I don't think this is an isolated problem, I have exactly the same on jgit using ssh credentials doesn't work, and I get the same stacktrace, using the latest git client plugin.
          I'm using credentials that should retrieve keys from the .ssh directory.

          krzyk added a comment - markewaite I don't think this is an isolated problem, I have exactly the same on jgit using ssh credentials doesn't work, and I get the same stacktrace, using the latest git client plugin. I'm using credentials that should retrieve keys from the .ssh directory.

          Mark Waite added a comment -

          I'm reasonably confident it is an isolated problem.

          There are are many use models which use the JGit implementation with ssh credentials. There are automated tests of JGit with ssh credentials. I have acceptance test cases I regularly run from a docker instance to confirm JGit with ssh credentials to multiple servers, including a personal ssh based git server, assembla, bitbucket, github, and gitlab. Those tests are all passing.

          If it weren't an isolated problem, I'd expect more of the installations to be reporting the issue, especially since the last comment on this closed bug report is from Aug 2015.

          Mark Waite added a comment - I'm reasonably confident it is an isolated problem. There are are many use models which use the JGit implementation with ssh credentials. There are automated tests of JGit with ssh credentials. I have acceptance test cases I regularly run from a docker instance to confirm JGit with ssh credentials to multiple servers, including a personal ssh based git server, assembla, bitbucket, github, and gitlab. Those tests are all passing. If it weren't an isolated problem, I'd expect more of the installations to be reporting the issue, especially since the last comment on this closed bug report is from Aug 2015.

          guss77 I have the same issue, have you managed to solve it?

          Tidhar Klein Orbach added a comment - guss77 I have the same issue, have you managed to solve it?

          Mark Waite added a comment -

          I'm still not able to duplicate this with the current code. Automated and interactive tests of JGit with an RSA private key continue to run correctly on Windows, Ubuntu 12, Ubuntu 14, Debian 7, Debian 8, Debian 9 pre-release, CentOS 6, and CentOS 7. The tests uses private git repositories on assembla, bitbucket, gitlab, github, and on two different private computers that I host at home.

          I have 2 JGit based failures in the automated test suite that are only visible when using the git client plugin 1.20 beta and the git plugin 2.5 beta with submodule authentication configured to use the credentials of the parent repository. If that's the case you're seeing, please share that information.

          If you have more details, or a publicly accessible way to duplicate the bug, I'm certainly interested. I'm also interested if you've been able to successfully connect to the same repository with command line git rather than JGit.

          Mark Waite added a comment - I'm still not able to duplicate this with the current code. Automated and interactive tests of JGit with an RSA private key continue to run correctly on Windows, Ubuntu 12, Ubuntu 14, Debian 7, Debian 8, Debian 9 pre-release, CentOS 6, and CentOS 7. The tests uses private git repositories on assembla, bitbucket, gitlab, github, and on two different private computers that I host at home. I have 2 JGit based failures in the automated test suite that are only visible when using the git client plugin 1.20 beta and the git plugin 2.5 beta with submodule authentication configured to use the credentials of the parent repository. If that's the case you're seeing, please share that information. If you have more details, or a publicly accessible way to duplicate the bug, I'm certainly interested. I'm also interested if you've been able to successfully connect to the same repository with command line git rather than JGit.

          Oded Arbel added a comment -

          tizkiko : Haven't happened to me for a while now, I don't remember what I changed - if at all.

          Oded Arbel added a comment - tizkiko : Haven't happened to me for a while now, I don't remember what I changed - if at all.

          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
          

          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

          Mark Waite added a comment -

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

          Mark Waite added a comment - dc00 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.

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

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

          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.

          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.

          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

          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

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

              Created:
              Updated:
              Resolved: