Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Hudson » Poll git via gitolite works, clone and fetch fail(Error cloning remote repo 'origin' although repository polling triggers builds)
Poll git via gitolite works, clone and fetch fail [message #1075822] Tue, 30 July 2013 06:16 Go to next message
Bruce AtEconz is currently offline Bruce AtEconzFriend
Messages: 6
Registered: July 2013
Junior Member
I have a repository on one server, which has a gitolite service running on it. Authentication is done with OpenSSH and RSA certificates.

Hudson 3.0 is running on another CentOS 6.4 server as the hudson user. I had to do a bit of fiddling with config files to get the ssh-agent working for the hudson process.

I added the following lines to /etc/sysconfig/hudson:
export HOME=${HUDSON_HOME}
export BASH_ENV=${HOME}/.bash_profile


And then in .bash_profile:
SSH_ENV="${HOME}/.ssh/environment"

function start_agent {
    echo "Initialising new SSH agent..."
    ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
    echo "succeeded"
    chmod 600 "${SSH_ENV}"
    . "${SSH_ENV}" > /dev/null
    ssh-add ${HOME}/.ssh/myrepo_key;
}

# Source SSH settings, if applicable

if [ -f "${SSH_ENV}" ]; then
    . "${SSH_ENV}" > /dev/null
    #ps ${SSH_AGENT_PID} doesn't work under cywgin
    ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
        start_agent;
    }
else
    start_agent;
fi


This gives me the following .ssh/environment file:
SSH_AUTH_SOCK=/tmp/ssh-abcdef1234/agent.1234; export SSH_AUTH_SOCK;
SSH_AGENT_PID=1234; export SSH_AGENT_PID;


All the above I found on some forums somewhere, but it seems to work well enough. I reboot the server and the ssh-agent process is running for hudson, it runs my bash_profile script, etc.


At this point I can log in as the hudson user and clone the repository.

In hudson my configuration is also pretty standard. I have set up a git repository url of:
ssh://git@reposerver/myrepo

and left everything else to default. The repo has defaulted to origin, the refspec has defaulted to "+refs/heads/*:refs/remotes/origin/*", the branch has defaulted to master. The build trigger is just a poll of the SCM.

And builds do appear to be getting started by code checkin. But the clone is failing.

The log message is:

Started by an SCM change
Checkout:workspace / /var/lib/hudson/jobs/myrepo/workspace - hudson.remoting.LocalChannel@7ad6edc7
Using strategy: Default
Last Built Revision: Revision c9b383ba7a454778bed00d76abcdb0b033c46dd3 (origin/master)
Checkout:workspace / /var/lib/hudson/jobs/myrepo/workspace - hudson.remoting.LocalChannel@7ad6edc7
Cloning the remote Git repository
Cloning repository origin
ERROR: Error cloning remote repo 'origin' 
hudson.plugins.git.GitException: Could not clone ssh://git@reposerver/myrepo
	at hudson.plugins.git.GitAPI.clone(GitAPI.java:241)
	at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:972)
	at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:919)
	at hudson.FilePath.act(FilePath.java:791)
	at hudson.FilePath.act(FilePath.java:773)
	at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:919)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:698)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1515)
	at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:521)
	at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:428)
	at hudson.model.Run.run(Run.java:1390)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:40)
	at hudson.model.ResourceController.execute(ResourceController.java:82)
	at hudson.model.Executor.run(Executor.java:137)
Caused by: hudson.plugins.git.GitException: org.eclipse.jgit.api.errors.TransportException: ssh://git@reposerver/myrepo: Auth cancel
	at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:234)
	at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:221)
	at hudson.FilePath.act(FilePath.java:791)
	at hudson.FilePath.act(FilePath.java:773)
	at hudson.plugins.git.GitAPI.clone(GitAPI.java:221)
	... 13 more
Caused by: org.eclipse.jgit.api.errors.TransportException: ssh://git@reposerver/myrepo: Auth cancel
	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:137)
	at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:179)
	at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125)
	at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:228)
	... 17 more
Caused by: org.eclipse.jgit.errors.TransportException: ssh://git@reposerver/myrepo: Auth cancel
	at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:142)
	at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121)
	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:1104)
	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:128)
	... 20 more
Caused by: com.jcraft.jsch.JSchException: Auth cancel
	at com.jcraft.jsch.Session.connect(Session.java:481)
	at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
	... 27 more
Trying next repository
FATAL: Could not clone repository
hudson.plugins.git.GitException: Could not clone repository
	at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:983)
	at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:919)
	at hudson.FilePath.act(FilePath.java:791)
	at hudson.FilePath.act(FilePath.java:773)
	at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:919)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:698)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1515)
	at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:521)
	at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:428)
	at hudson.model.Run.run(Run.java:1390)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:40)
	at hudson.model.ResourceController.execute(ResourceController.java:82)
	at hudson.model.Executor.run(Executor.java:137)


SO what have I missed?
Re: Poll git via gitolite works, clone and fetch fail [message #1077570 is a reply to message #1075822] Thu, 01 August 2013 22:25 Go to previous messageGo to next message
Bruce AtEconz is currently offline Bruce AtEconzFriend
Messages: 6
Registered: July 2013
Junior Member
Fetch seems to work fine. After setting the hudson logs to a level of FINE:

Aug 2, 2013 10:06:41 AM hudson.Proc
FINE: Running: git rev-parse origin/master

Aug 2, 2013 10:06:41 AM hudson.Proc
FINE: Running: git tag -l master

Aug 2, 2013 10:06:41 AM hudson.Proc
FINE: Running: git fetch -t ssh://git@reposerver/myrepo +refs/heads/*:refs/remotes/origin/*

Aug 2, 2013 10:06:41 AM hudson.model.AbstractProject
FINE: Polling SCM changes of myrepo

Aug 2, 2013 10:06:41 AM hudson.slaves.WorkspaceList
FINE: SCM polling for FreeStyleProject[myrepo] acquired /var/lib/hudson/jobs/myrepo/workspace

Aug 2, 2013 10:06:41 AM hudson.triggers.SCMTrigger
FINE: scheduling the trigger to (asynchronously) run

Aug 2, 2013 10:06:41 AM hudson.triggers.SCMTrigger
FINE: Scheduling a polling for FreeStyleProject[myrepo]

Aug 2, 2013 10:06:41 AM hudson.triggers.Trigger
CONFIG: cron triggered myrepo

Aug 2, 2013 10:06:41 AM hudson.triggers.Trigger
FINE: cron checking myrepo

Aug 2, 2013 10:06:41 AM hudson.triggers.Trigger
FINE: cron checking Aug 2, 2013 10:06:17 AM
Re: Poll git via gitolite works, clone and fetch fail [message #1077677 is a reply to message #1077570] Fri, 02 August 2013 02:17 Go to previous messageGo to next message
Winston Prakash is currently offline Winston PrakashFriend
Messages: 434
Registered: August 2011
Location: Fremont, CA USA
Senior Member
Means it is working ok for you now?

Winston Prakash
Eclipse Hudson team
Re: Poll git via gitolite works, clone and fetch fail [message #1079614 is a reply to message #1077677] Sun, 04 August 2013 21:55 Go to previous messageGo to next message
Bruce AtEconz is currently offline Bruce AtEconzFriend
Messages: 6
Registered: July 2013
Junior Member
Not it is not working. What my second comment meant was that Hudson seems to be able to poll the repo server and picks up when a commit is made. But it will not download the code from the repo server, so therefore is not able to build and run it. It still throws the error shown in the first comment when it tries to get the code.
Re: Poll git via gitolite works, clone and fetch fail [message #1080325 is a reply to message #1079614] Mon, 05 August 2013 20:01 Go to previous messageGo to next message
Winston Prakash is currently offline Winston PrakashFriend
Messages: 434
Registered: August 2011
Location: Fremont, CA USA
Senior Member
Looking at the exception again, it looks like it is failing at SSH authentication

Caused by: org.eclipse.jgit.errors.TransportException: ssh://git@reposerver/myrepo: Auth cancel

I have never setup SSH auth like how you set up. I always use public/private key as explained here http://gitolite.com/gitolite/glssh.html





Winston Prakash
Eclipse Hudson team
Re: Poll git via gitolite works, clone and fetch fail [message #1080600 is a reply to message #1080325] Tue, 06 August 2013 06:35 Go to previous messageGo to next message
Bruce AtEconz is currently offline Bruce AtEconzFriend
Messages: 6
Registered: July 2013
Junior Member
Hi Winston,

Thanks for your reply. I agree it does look some sort of authentication problem.

I read the page you linked to. This describes how to set up gitolite on the server, but that is already working find for us, and has been for a long time. I don't have any control of the box running gitolite (reposerver) but I showed your comment to the system administrator responsible for reposerver, and he believes it is set up the same as described in the gitolite page.

The page doesn't say anything about configuring hudson as a client to gitolite, except to use ssh-keygen to generate an RSA key pair. I already have the key and know that it works. I have also tried running a terminal as the hudson user ( su - hudson -s /bin/bash ) and using the same public/private key pair. I can clone or fetch from reposerver, so the keys themselves are ok.

Your quote, "I have never setup SSH auth like how you set up. I always use public/private key as explained here.." I am using a public/private key as described on the page. ssh-agent is just the means by which the key pair is made available to hudson. On most linuxes, within a user terminal, ssh-agent Just Works(tm) so most users are not aware of it. The only reason I had to mess around with it was because hudson is running as daemon as opposed to a user session.

I can't actually see any difference between the setup I described above and the page you linked to, with regard to being a client of gitolite and ssh. Are there some specific differences you're seeing that I've missed?

If you have used public/private key authentication with hudson before, how do you normally set it up? Perhaps there is some built-in hudson support, or a simpler environmental setup for this I'm not aware of.

One other interesting thing I noticed in hudson's behaviour is that it appears to be running two builds for every checkin. ANd the log output from each one is different. The first one produces the following output:

Polling log:
Started on Aug 6, 2013 3:22:41 PM
Using strategy: Default
[poll] Last Build : #28
[poll] Last Built Revision: Revision c9b383ba7a454778bed00d76abcdb0b033c46dd3 (origin/master)
Fetching changes from the remote Git repositories
Fetching upstream changes from ssh://git@reposerver/myrepo
Done. Took 0.44 sec
Changes found


Console output:
Started by an SCM change
Checkout:workspace / /var/lib/hudson/jobs/myrepo/workspace - hudson.remoting.LocalChannel@7ad6edc7
Using strategy: Default
Last Built Revision: Revision c9b383ba7a454778bed00d76abcdb0b033c46dd3 (origin/master)
Checkout:workspace / /var/lib/hudson/jobs/myrepo/workspace - hudson.remoting.LocalChannel@7ad6edc7
Fetching changes from the remote Git repository
Fetching upstream changes from ssh://git@reposerver/myrepo
Commencing build of Revision a576d37ea9e5c15423e0cdeb8780cabe8a816f0c (origin/master)
Checking out Revision a576d37ea9e5c15423e0cdeb8780cabe8a816f0c (origin/master)

Deleting project workspace... 
done

FATAL: Unable to find build script at /var/lib/hudson/jobs/myrepo/workspace/ant/build.xml
Sending e-mails to: xxx@xxx.xxx yyy@xxx.xxx
[DEBUG] Skipping watched dependency update for build: myrepo #29 due to result: FAILURE
Finished: FAILURE


Note: I would expect the build to find that build file.


The second build gives the following output:

Polling Log:
Started on Aug 6, 2013 3:23:41 PM
No workspace is available, so can't check for updates.
Scheduling a new build to get a workspace.
Done. Took 0 ms
Changes found


Console output:
Started by an SCM change
Checkout:workspace / /var/lib/hudson/jobs/myrepo/workspace - hudson.remoting.LocalChannel@7ad6edc7
Using strategy: Default
Last Built Revision: Revision a576d37ea9e5c15423e0cdeb8780cabe8a816f0c (origin/master)
Checkout:workspace / /var/lib/hudson/jobs/myrepo/workspace - hudson.remoting.LocalChannel@7ad6edc7
Cloning the remote Git repository
Cloning repository origin
ERROR: Error cloning remote repo 'origin' 
hudson.plugins.git.GitException: Could not clone ssh://git@reposerver/myrepo
	at hudson.plugins.git.GitAPI.clone(GitAPI.java:241)
	at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:972)
...

... etc. as above.

SO the authentication seems to be working find on build #29, but failing for build #30.

Why the difference?

[Updated on: Tue, 06 August 2013 23:12]

Report message to a moderator

Re: Poll git via gitolite works, clone and fetch fail [message #1081167 is a reply to message #1080600] Tue, 06 August 2013 22:43 Go to previous messageGo to next message
Bruce AtEconz is currently offline Bruce AtEconzFriend
Messages: 6
Registered: July 2013
Junior Member
So I have made some progress here. Examining the build configuration, I noticed a checkbox option, "Delete workspace before build starts," which was checked by default. I must admit I boggled a bit at this one. There can't be many people who want to do this, and it certainly wasn't helping me. I unchecked it and things magically started working.

In the spirit of experimentation though, I tried changing another option, "Delete workspace when build is done ." This was unchecked by default and I checked it. This caused all my builds to start failing with the original, "Error cloning remote repo," error message again. When I unchecked it again, the first successive build failed the same way, but the second and all following successive builds started working again.

So long story short, I now have a working Hudson system. But I'm going to go out on a limb here, and say that there is a bug in Hudson, or one or more of it's plugins, if it can fail some of the time but also succeed some of the time fetching from the same repository with the same key.
Re: Poll git via gitolite works, clone and fetch fail [message #1081178 is a reply to message #1081167] Tue, 06 August 2013 23:10 Go to previous message
Bruce AtEconz is currently offline Bruce AtEconzFriend
Messages: 6
Registered: July 2013
Junior Member
Thinking about it, "Delete workspace before build starts," is probably meant to mean delete the old workspace before checking out the new workspace. In my case thgough, that didn't seem to be happening. See the logs:

Started by user anonymous
Checkout:workspace / /var/lib/hudson/jobs/myrepo/workspace - hudson.remoting.LocalChannel@7ad6edc7
Using strategy: Default
Last Built Revision: Revision a576d37ea9e5c15423e0cdeb8780cabe8a816f0c (origin/master)
Checkout:workspace / /var/lib/hudson/jobs/myrepo/workspace - hudson.remoting.LocalChannel@7ad6edc7
Fetching changes from the remote Git repository
Fetching upstream changes from ssh://git@reposerver/myrepo
Commencing build of Revision a576d37ea9e5c15423e0cdeb8780cabe8a816f0c (origin/master)
Checking out Revision a576d37ea9e5c15423e0cdeb8780cabe8a816f0c (origin/master)

Deleting project workspace... 
done

FATAL: Unable to find build script at /var/lib/hudson/jobs/myrepo/workspace/ant/build.xml
Sending e-mails to: xxx@xxx.xxx yyy@xxx.xxx
[DEBUG] Skipping watched dependency update for build: myrepo #34 due to result: FAILURE
Finished: FAILURE

[Updated on: Tue, 06 August 2013 23:13]

Report message to a moderator

Previous Topic:Bulk Copy
Next Topic:Hudson changes between two builds
Goto Forum:
  


Current Time: Sat Nov 22 01:53:47 GMT 2014

Powered by FUDForum. Page generated in 0.02533 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software