Git plugin unable to acces local repository

699 views
Skip to first unread message

Henk van Voorthuijsen

unread,
Oct 1, 2015, 12:10:55 PM10/1/15
to Jenkins Users
Hi,

I'm having trouble getting access to a local git repository:

System: CentOS 7

I'm running Jenkins as a service using system

When I try to set up a job with Git, the URL field shows the following error:


Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h git@localhost:repositories/puq HEAD" returned status code 128:
stdout: 
stderr: Permission denied, please try again. 
Permission denied, please try again. 
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). 
fatal: Could not read from remote repository.

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


In order to test what is happening, I run the following script:

whoami
echo $USER
cd /tmp
rm -rf test
mkdir test
cd test
git clone git@localhost:repositories/puq

 Which gives the following output:

+ whoami
jenkins
+ echo jenkins
jenkins
+ cd /tmp
+ rm -rf test
+ mkdir test
+ cd test
+ git clone git@localhost:repositories/puq
Cloning into 'puq'...
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

So, basically the same error.

When I run the same clone command from the command line (logged in as jenkins), however, the clone succeeds...

I have the feeling I'm missing something obvious - can anyone tell me what's going on?

Henk van Voorthuijsen

Mark Waite

unread,
Oct 1, 2015, 1:35:59 PM10/1/15
to Jenkins Users
Did you define a credential and reference that credential when you defined the git settings in the job definition?  The run time environment may be different between your logging in as the jenkins user with an interactive shell and your running jenkins as a CentOS 7 service.

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/4e09f72f-f23b-4eeb-8eb7-4779df08cee1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Henk van Voorthuijsen

unread,
Oct 1, 2015, 4:38:38 PM10/1/15
to Jenkins Users
I did - there is a credential for user "git" in the global credentials.
But I noticed that $PWD is set to "/" - which is probably not what I want... I'll investigate further..

Henk van Voorthuijsen

unread,
Oct 1, 2015, 4:59:44 PM10/1/15
to Jenkins Users
OK, I set the service's WorkingDirectory to $JENKINS_HOME -  unfortunately that doesn't help - I'm still getting the same error

milki milk

unread,
Oct 2, 2015, 12:12:40 PM10/2/15
to Jenkins Users
Did you set the credentials to be used the scm section? You need to both define the credentials _and_ use the credentials.

Henk van Voorthuijsen

unread,
Oct 4, 2015, 8:06:39 AM10/4/15
to Jenkins Users
I added credentials using the "Add" button ; they showed up in the selection box; I selected them. I would think that is enough. Is it?

milki milk

unread,
Oct 12, 2015, 12:03:10 PM10/12/15
to Jenkins Users
Yes, that should be it. Defined credentials and using that credential in the selection box for your scm. Are you sure the credentials work? I see you are also using localhost. The scm polling job doesn't havee a node restriction, but the job that does the checkout is done locally on the node it runs on. In general, you'll want the server to be accessible from all nodes.
Reply all
Reply to author
Forward
0 new messages