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

GIT_SSH not always used for git fetch

XMLWordPrintable

      I have an OS X slave.

      The Jenkins job is configured to connect to the git repository using a private key.

      Most of the times when fetching git changes the GIT_SSH is used:

      [EnvInject] - Loading node environment variables.
      Building remotely on MobileDaily in workspace /opt/dailybuild/jenkins/workspace/Dev MerchantApp iOS
       > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
       > git config remote.origin.url git@bitbucket.org:vo/demo-merchant-ios.git # timeout=10
      Fetching upstream changes from git@bitbucket.org:vo/demo-merchant-ios.git
       > git --version # timeout=10
      using GIT_SSH to set credentials
       > git fetch --tags --progress git@bitbucket.org:vo/demo-merchant-ios.git +refs/heads/*:refs/remotes/origin/*
      

      But after some time, it is not used anymore, and git fetching fails:

      [EnvInject] - Loading node environment variables.
      Building remotely on MobileDaily in workspace /opt/dailybuild/jenkins/workspace/Dev MerchantApp iOS
       > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
       > git config remote.origin.url git@bitbucket.org:vo/demo-merchant-ios.git # timeout=10
      Cleaning workspace
       > git rev-parse --verify HEAD # timeout=10
      Resetting working tree
       > git reset --hard # timeout=10
       > git clean -fdx # timeout=10
      Fetching upstream changes from git@bitbucket.org:vo/demo-merchant-ios.git
       > git --version # timeout=10
       > git fetch --tags --progress git@bitbucket.org:vo/demo-merchant-ios.git +refs/heads/*:refs/remotes/origin/*
      FATAL: Failed to fetch from git@bitbucket.org:vo/demo-merchant-ios.git
      hudson.plugins.git.GitException: Failed to fetch from git@bitbucket.org:vo/demo-merchant-ios.git
      	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:627)
      	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:865)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:890)
      	at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:652)
      	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:561)
      	at hudson.model.Run.execute(Run.java:1665)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      	at hudson.model.ResourceController.execute(ResourceController.java:88)
      	at hudson.model.Executor.run(Executor.java:246)
      Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@bitbucket.org:vo/demo-merchant-ios.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
      stdout: 
      stderr: Permission denied (publickey).
      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:1437)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1225)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:87)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:282)
      	at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:153)
      	at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:146)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:118)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      	at hudson.remoting.Request$2.run(Request.java:328)
      	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:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:724)
      
      

      The only solution I have found is:
      Disconnecting and reconnecting the Slave.
      Most of the times it helps, but not always.

            ndeloof Nicolas De Loof
            xfreebird Nicolae Ghimbovschi
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: