Git pull from GitHub private repository

51 views
Skip to first unread message

han...@nd.edu

unread,
Dec 19, 2016, 4:10:26 PM12/19/16
to Jenkins Users
I'm attempting to pull from a private repository in GitHub. I have keys set up so that the jenkins user can pull from the repository but am having trouble with the Git plugin. When I set the repository URL to:


I receive the error message:

Failed to connect to repository : Command "git ls-remote -h g...@github.com:[myorg]/[myrepo] HEAD" returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: The remote end hung up unexpectedly

However, from the command line, this works:

git ls-remote  g...@github.com:[myorg]/[myrepo] HEAD
d028a33d1bc3bc4cec49ae53f80f3eb58f09f13d HEAD

and this also gives output:

git ls-remote -h g...@github.com:[myorg/[myrepo]
d028a33d1423bc4cec49ae53f80f3eb5bc09f13d refs/heads/master

It is the combination of using both -h and HEAD that gives bad output.

Do I have something wrong with the repository?  Or something wrong with the plugin?  Or what am I missing here?

Thanks,
Tom Hanstra




Mark Waite

unread,
Dec 19, 2016, 7:22:06 PM12/19/16
to Jenkins Users
Did you define a credential for the access to that repository (using the "Add" button on the job UI, or using the credentials section in "Manage Jenkins")?

Is the credential you defined a private key (not a username / password) credential?  If not, it needs to be.

Did you associate that credential with that repository URL in the job definition?

Is the public key for that private key registered with github as an allowed public key for that repository?

Are you using any entries in ~/.ssh/config to use unexpected or different private keys in your access to the github repository?

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f1fb8b49-ed9f-4f19-ae6e-dc3960b5a212%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

han...@nd.edu

unread,
Dec 20, 2016, 10:12:44 AM12/20/16
to Jenkins Users
Looks like switching to the jenkins user ssh-keys credentials helps move this forward. The errors I was getting first were directly in the configuration of Jenkins. Telling Jenkins to use the ssh-key for the Jenkins user gets me past that.

But on deploy, I'm still getting github errors.  When I run this command interactively:

SCM_BRANCH="master" /opt/ruby/current/bin/cap -v -f "./Capfile" pre_production deploy

The deploy works properly. But when Jenkins tries to run the same basic command, the console gives this error:

SCM_BRANCH=master
+ /opt/ruby/current/bin/cap -v -f /opt/jenkins/jobs/fw-test/workspace/Capfile pre_production deploy
 ** transaction: start
/opt/ruby/2.0.0-p353/lib/ruby/gems/2.0.0/gems/capistrano-2.12.0/lib/capistrano/recipes/deploy.rb:107: warning: Insecure world writable dir /opt/jenkins/tools/hudson.model.JDK/java_7_u55 in PATH, mode 040777
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
*** [deploy:update_code] rolling back
Command git ls-remote g...@github.com:ndlib/fw-test.git master returned status code pid 114306 exit 128
Build step 'Execute shell' marked build as failure

Any thoughts on what it does not like? 

Thanks,
Tom

han...@nd.edu

unread,
Dec 20, 2016, 10:36:11 AM12/20/16
to Jenkins Users
I figured out that the user root was doing the work of the deployment. Set up keys accordingly. 

Looks like I can deploy as expected after that.

Tom
Reply all
Reply to author
Forward
0 new messages