Failed to fetch from git@github.com

660 views
Skip to first unread message

john....@gmail.com

unread,
May 11, 2014, 8:38:18 AM5/11/14
to jenkins...@googlegroups.com

Okay, I am a newbie to Jenkins.

I'm reading Jenkins: The Definitive Guide and am attempting to set up the first example.

I'm having issues and I've searched and haven't really found an answer.

So, I am posting here in the hopes that this is a simple configuration issue.

I've done the following:

  • Set up Jenkins as a windows service and installed the Git Plugin
  • Used Git-Bash to open a window and create the key pair
  • Copied the public key to my Git account
  • Cloned the Git repository as directed in the book's example

However, I am seeing the following error message each time Jenkins attempts to pull changes from the Git repository:

Started by an SCM change:

Building in workspace C:\Jenkins\workspace\game-of-life-default
 git.exe rev-parse --is-inside-work-tree
Fetching changes from the remote Git repository
 git.exe config remote.origin.url g...@github.com:xxxx-xxxxxx/game-of-life.git
Fetching upstream changes from g...@github.com:xxxx-xxxxx/game-of-life.git
 git.exe --version
 git.exe fetch --tags --progress g...@github.com:xxxx-xxxxx/game-of-life.git +refs/heads/*:refs/remotes/origin/*

ERROR: Timeout after 10 minutes

FATAL: Failed to fetch from g...@github.com:xxxx-xxxxx/game-of-life.git

hudson.plugins.git.GitException: Failed to fetch from g...@github.com:xxxx-xxxxx/game-of-life.git

Finally returning with a status code: -1.

Any help would be appreciated.

Thanks

Mark Waite

unread,
May 11, 2014, 9:58:48 AM5/11/14
to jenkins...@googlegroups.com
You will probably have a better chance of success if you update your credentials plugin to the latest version, register your private key in the "Manage Jenkins", "Manage Credentials" section, then use that registered credential with your job.  That has the benefit that the private key is managed by Jenkins and will be used on slaves and masters as needed.

You could also try the same operations without installing git at all, if you use "Manage Jenkins" to add "JGit" as an installation of git.  The JGit implementation is not yet at functional parity with the command implementation, but it is pure Java so the use cases which it handles are all handled in Java, without requiring installation of a separate program.

I believe that "Jenkins the Definitive Guide" was published before the Credentials plugin was used by the git plugin.

Mark Waite


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks!
Mark Waite

Daniel Beck

unread,
May 11, 2014, 10:29:01 AM5/11/14
to jenkins...@googlegroups.com

On 11.05.2014, at 15:58, Mark Waite <mark.ea...@gmail.com> wrote:

> I believe that "Jenkins the Definitive Guide" was published before the Credentials plugin was used by the git plugin.

The Credentials plugin 1.0 was released over two years ago in early 2012.

The book was published in 2011, around the time of 1.423. It even says when they started work on the book, it was supposed to be about Hudson (and many screenshots show Hudson -- others show Jenkins 1.410).

Mark Waite

unread,
May 11, 2014, 10:48:27 AM5/11/14
to jenkins...@googlegroups.com
I think git plugin use of the credentials plugin is even newer than the credentials plugin.  The first commit reference to credentials in the git-client-plugin is from 2013, long after the publication date of the book.

I believe the author of "Jenkins - The Definitive Guide" is preparing revisions to the book (based on other comments on the mailing list).


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks!
Mark Waite

john....@gmail.com

unread,
May 11, 2014, 12:45:34 PM5/11/14
to jenkins...@googlegroups.com
Thank You for the prompt response!

I've been struggling with this, off and on, for a couple of weeks now and am very grateful for any guidance.

So, with that in mind, and in the hopes I can get my installation correct, I'm starting with a completely clean install.  I've removed the old instance of Jenkins locally and even removed the old keys from my git account.

Here are the steps, I am following:

1) Downloaded the latest Jenkins 1.562.zip
2) Installed to C:\Jenkins (because in my experience "Program Files" with a space in the middle is problematic)
3) Installed the Git Client Plugin 1.10 from the Manage Plugins page under Manage Jenkins
4) Went to https://help.github.com/articles/generating-ssh-keys and followed the instructions to generate new keys
4a) Note: I had already installed GitBash and so performed all the following steps in a command window opened from Git Bash.
4b) Note: When executing ssh-add ~/.ssh/id_rsa I got the error message "Could not open a connection to your authentication agent."
      (Not sure if that is a show stopper for Jenkins, so I pressed on.)
5) Ran the following steps to add my new SSH keys to GitHub
5a) "clip < ~/.ssh/id_rsa.pub"
5b) Logged into my GitHib account, using the link: https://help.github.com/articles/generating-ssh-keys, and added my new key to my account.
6) Testing results:
     $ ssh -T g...@github.com
     The authenticity of host 'github.com (192.30.252.128)' can't be established.
     RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
     Are you sure you want to continue connecting (yes/no)? yes
     Warning: Permanently added 'github.com,192.30.252.128' (RSA) to the list of known hosts.
     Enter passphrase for key '/c/Users/xxxxxx/.ssh/id_rsa':
     Hi john...! You've successfully authenticated, but GitHub does not provide shell access.
7) Returned to my Git Bash Window and forked the sample repository using the following command:
    git clone g...@github.com:xxxx-xxxxxx/game-of-life.git
7a) $ git clone g...@github.com:john-meloro/game-of-life.git
        Cloning into 'game-of-life'...
        Warning: Permanently added the RSA host key for IP address '192.30.252.130' to the list of known hosts.
        Enter passphrase for key '/c/Users/xxxxxx/.ssh/id_rsa':
        remote: Reusing existing pack: 9139, done.
        remote: Total 9139 (delta 0), reused 0 (delta 0)
        Receiving objects: 100% (9139/9139), 17.34 MiB | 849.00 KiB/s, done.
        Resolving deltas: 100% (5704/5704), done.
        Checking connectivity... done.
        Checking out files: 100% (1518/1518), done.
8) Next, I went back to Jenkins.  I have already installed Java 1.7 and Maven 3.x installed locally so I used them in my Jenkins configuration in lieu of    
    downloading new installations.
9) Setting up my Jenkins build job went like this:
9a) Clicked "New Item" from "Configure Jenkins"
9b) Selected "Build a free-style software project" (As per the instructions in Jenkins: The definitive Guide"
9c) Now comes the interesting part!
9d) Under "
Source Code Management"
9e) Selected Git; Git Repositories;
Repository URL: g...@github.com:xxxx-xxxxx/game-of-life.git
9f) But got the following error before I could complete the configuration:
       Failed to connect to repository : Command "git.exe ls-remote -h g...@github.com:john-meloro/game-of-life.git HEAD" 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.
9g)  However, I did add the following under "Add Credentials"
       Kind: SSH Username with private key
       Username: xxxx-xxxxxx
       Description: SSH Username with private key
       Private Key: (tried all three options)
       Pass Phrase: (Entered the correct pass phrase)

And that is about as far as I'm getting.


Any help would be appreciated.

Thanks.

John Meloro

unread,
May 11, 2014, 5:26:09 PM5/11/14
to jenkins...@googlegroups.com
I tried the Credentials Plugin, but could not get it to work either.

I am out of ideas and am giving up.  I've tried for two weeks and am no closer now than when I started.

I've un-installed Jenkins and deleted my GitHub account.

Signing off and moving on...



--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/P8mAVI9cROU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.

Stephen Connolly

unread,
May 11, 2014, 5:33:37 PM5/11/14
to jenkins...@googlegroups.com
You should enter the username as git and not put the git@ in the scm url.

What is happening is that github expects that the username for your key will *always* be "git". When you specify a username in an ssh key, the git plugin then replaces the git@ with your username... so despite the fact that my github username is stephenc I put the username of the private key my jenkins uses to connect to github as "git" and it should all "just work™"

HTH

john....@gmail.com

unread,
May 25, 2014, 9:56:31 AM5/25/14
to jenkins...@googlegroups.com
Okay, I re-attempting to configure my Jenkins correctly.

Here is where I am coming off the rails:

  • When I leave out the "git@" in the SCM URL in the Source Code Management section, I immediately get the following error:
    • "Failed to connect to repository : Command "git.exe ls-remote -h github.com:jmeloro/game-of-life.git HEAD" 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.

Likewise when I attempt to run the following command in gitBash:

$ git.exe ls-remote -h github.com:jmeloro/game-of-life.git HEAD


Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

So, I am thinking that my public/private keys are still not setup correctly.

Any help will be appreciated.

Thanks,


John Meloro

unread,
May 25, 2014, 1:50:04 PM5/25/14
to jenkins...@googlegroups.com
I've tinkered around some more.

I've copied the private key to the directory where the local system account is running because on my Windows 7 box I've read that as a service Jenkins runs under the local system account.

I still do not have the configuration correct.  However, I am able to get past configuring the Source Code Management section.

I'm getting the following error now when I attempt to build:
Started by user anonymous
Building in workspace C:\Jenkins\workspace\game-of-life-default
 > git.exe rev-parse --is-inside-work-tree
Fetching changes from the remote Git repository
 > git.exe config remote.origin.url g...@github.com:jmeloro/game-of-life.git
Fetching upstream changes from g...@github.com:jmeloro/game-of-life.git
 > git.exe --version
using GIT_SSH to set credentials SSH Username with private key
 > git.exe fetch --tags --progress g...@github.com:jmeloro/game-of-life.git +refs/heads/*:refs/remotes/origin/*
ERROR: Timeout after 10 minutes
FATAL: Failed to fetch from g...@github.com:jmeloro/game-of-life.git
hudson.plugins.git.GitException: Failed to fetch from g...@github.com:jmeloro/game-of-life.git
	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:623)
	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:855)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:880)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1251)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:513)
	at hudson.model.Run.execute(Run.java:1706)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:88)
	at hudson.model.Executor.run(Executor.java:231)
Caused by: hudson.plugins.git.GitException: Command "git.exe fetch --tags --progress g...@github.com:jmeloro/game-of-life.git +refs/heads/*:refs/remotes/origin/*" returned status code -1:
stdout: 
stderr: 
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1325)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1186)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:87)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:257)
	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:621)
	... 10 more



--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/P8mAVI9cROU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.

Stephen Connolly

unread,
May 25, 2014, 6:39:17 PM5/25/14
to jenkins...@googlegroups.com
But are you selecting a credential who's username is git and who's private key is the key you want Jenkins to access with?

Until you select that credential you will - correctly - see the warning.  

If you can't see the credentials drop down then upgrade the git plugin to at least the 2.x


--
Sent from my phone

john....@gmail.com

unread,
May 25, 2014, 8:49:35 PM5/25/14
to jenkins...@googlegroups.com
Thank you for the reply.

However, I still need some clarification.

I'm attempting to run Jenkins as a Windows Service, so Jenkins is running under the Local System Account.  So, I am not sure what to use for the username?

However, when I set up the build job, under the Source Code Management section, I do not see anything in the credentials drop down.

So, picking up from there, here is how I am attempting to set up this section:

I choose "Git" from the radio-buttons.

And enter the following for the Repository URL: github.com:<user name>/game-of-life.git

I click on "Add" and being presented with the "Add Credentials" window:

1) I choose "SSH Username with private key" for kind
2) I choose "Scope" to be Global
3) I choose "Username" to be "git"
4) I copy the private key directly into the text area and click "add"
5) Under "Advanced" I enter the pass-phrase
6) Finally, I click add and that is when I get the following error message:

Failed to connect to repository : Command "git.exe ls-remote -h github.com:jmeloro/game-of-life.git HEAD" returned status code -1:
stdout:
stderr:

Any corrections you could give me to the procedure I am following would be greatly appreciated.

Thanks
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Daniel Beck

unread,
May 26, 2014, 5:38:43 AM5/26/14
to jenkins...@googlegroups.com

On 26.05.2014, at 02:49, john....@gmail.com wrote:

> I'm attempting to run Jenkins as a Windows Service, so Jenkins is running under the Local System Account

That's just the default. You can configure the service to run as different user.

john....@gmail.com

unread,
May 26, 2014, 8:10:23 AM5/26/14
to jenkins...@googlegroups.com, m...@beckweb.net
That's just the default. You can configure the service to run as different user.

Okay, how would I do that?

john....@gmail.com

unread,
May 26, 2014, 8:14:12 AM5/26/14
to jenkins...@googlegroups.com, m...@beckweb.net
> That's just the default. You can configure the service to run as different user.

Also, would I need to re-create the public/private keys while logged in as that user?


On Monday, May 26, 2014 5:38:43 AM UTC-4, Daniel Beck wrote:

John Meloro

unread,
May 26, 2014, 12:43:52 PM5/26/14
to jenkins...@googlegroups.com
So, more troubleshooting...

I am able to successfully run the following command, using Git Bash, from the directory that contains my cloned repository.

git.exe fetch --tags --progress g...@github.com:jmeloro/game-of-life.git +refs/heads/*:refs/remotes/origin/*

The "catch" is that I am prompted for the pass phrase!

I suspect that what is happening is that "behind the scenes" a pass phrase is being requested
and since it never gets entered a timeout occurs.

So, the next step is to trouble shoot the credentials plugin.



You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/P8mAVI9cROU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.

Mark Waite

unread,
May 26, 2014, 12:56:39 PM5/26/14
to jenkins...@googlegroups.com
Alternately, couldn't you generate a private key which does not require a passphrase and use that instead?

There is at least one bug logged against the git plugin or the git client plugin that declares it does not support private keys which require a passphrase.


Mark Waite

john....@gmail.com

unread,
May 26, 2014, 10:05:17 PM5/26/14
to jenkins...@googlegroups.com
It seems that even though there is a field for the passphrase when I add the credentials, I have not been able to get the git plugin, ver. 2.2.1, under Windows 7 to work.

Looks like the next step is to try a public/private key pair that does not have a passphrase.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Sent from my phone

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/P8mAVI9cROU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks!
Mark Waite

lochrann

unread,
Jun 25, 2014, 1:43:39 PM6/25/14
to jenkins...@googlegroups.com
Hi everybody.

John, I've started reading Jenkins: The Definitive Guide today (I'm a Jenkins newbie too) and I've had the very same problem as you.
It's been driving me mad all day long.. Stuck at page 24 - ho la la.
I thought that it was because my Git directory was not at the default place (G:\Git\ instead of C:\Program Files (x86)) and
wasted a lot of time trying to generate a link/directory junction... But nope.

I finally hit this post and tried ssh without passphrase an *it worked!*

My local configuration is:
Git directory: G:\Git
Git plugin version: 2.2.2
Git client plugin version 1.9.1

Gobal Jenkins configuration:      Section Git
                Name: Git
                Path to Git executable: G:\Git\bin\git.exe

                Section CVS
                Private key location: G:/Git/.ssh/id_rsa
                Private Key Password: none (displays *********)
                Known Hosts Location: G:/Git/.ssh/known_hosts

Project configuration:       
                Source Code Management
                Git Repository URL g...@github.com:{my login}/game-of-life.git
                Credentials: none

Please note that I had to copy the ~/.ssh files in G:/Git/.ssh too.

So:
- try ssh without passphrase in Jenkins at least when it comes down to the book examples;
- copy your ssh files in the Git/.ssh directory next to the Git/bin directory.

Regards, Lochrann

John Meloro

unread,
Jun 26, 2014, 10:49:36 AM6/26/14
to jenkins...@googlegroups.com
Thank you for looking into this as well! 

I will try to recreate your solution.

Thanks again,
John M.



330.gif
Reply all
Reply to author
Forward
0 new messages