Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Error cloning remote repo 'origin', slave node

I need some help here, It's been a week I'm with this problem, can't figure out what's going on. I'm not able to clone a git repo from a slave node (Jenkins). I added the ssh key, host and slave (I've already tried generating a single key and one for each virtual and host)).

On Jenkins:

  • url:[email protected]: < repo>
  • Credentials: Here I tried with username/password, username with ssh file, username with ssh key directly, and -none-.

It doesn't seems like there is an authentication problem since I can clone the repo manually from console (both, slave and host). I can also connect with

ssh -T [email protected]

so the ssh key is fine, but when I build, this appear on console:

Building remotely on IE10Win7 in workspace C:\Users\IEUser\Desktop\< folder >

Wiping out workspace first.

Cloning the remote Git repository

Cloning repository [email protected]:< repo>.git

git init C:\Users\IEUser\Desktop\< folder> # timeout=10

ERROR: Error cloning remote repo 'origin'

ERROR: Error cloning remote repo 'origin'

Performing Post build task...

Does anyone have an idea? Hope someone can give me a clue, Thanks!

like image 473
Nicolas Amabile Avatar asked Mar 27 '15 13:03

Nicolas Amabile


People also ask

How do I resolve error cloning remote repo origin in Jenkins?

Go to your Windows slave configuration Manage Jenkins > Manage Nodes. Select your slave configuration. Check Tool Locations under Node Properties. Enter complete path to git executable including git.exe.

How can you clone a repository via Jenkins?

Configuring Git with Jenkins Now open your project and go to configure. Step 2: Give the repository Url in Source Code Management, repository Url can be fetched by clicking on clone and download option of Github and you have to select the SSH Url. Also, add credentials there of Jenkins.

Where does Jenkins clone the git repo?

After adding a new git repository (project configuration > Source Code Management > check the GIT option ) to the project navigate to the bottom of the plugin settings, just above Repository browser region.


3 Answers

I fixed this problem by setting the slave node tool path, selecting git and setting its value to

C:\Program Files (x86)\Git\bin\git.exe

Location: Configure Node - Tool Locations

like image 65
starlying Avatar answered Oct 24 '22 08:10

starlying


I recently updated several jenkins plugins and had this problem after the updates. Rolling back the git plugin didn't help, but I did a few other things to get it working. I listed all three here, but it was probably (2) that fixed the problem. Apparently the git executable was reset to default. So, configuring the git executable within the specific project was probably all that was needed. However the other items might come in handy too.

(1) The default git on a jenkins linux install geenrally points to /usr/lib... You need to specify a separate GitForWindows that points to the windows version:

Manage Jenkins
Configure System
Under Git - Git Installations
    Add Git -> Git
    Give it a name to be referenced in projects
      (mine is WindowsGit)
    Set Path to Git Executable
      (mine is "C:\Program Files (x86)\Git\bin\git.exe")
      (for recent git the path is "C:\Program Files\Git\bin\git.exe")

(2) Configure git on the specific project:

Select the project
Select Configure
Under Source Code Management - Git
    Select Git Executable as configured in 1)
    Set credentials or add new (ssh keys, etc)

(3) Updating the jenkins slave service to run as a specific user:

Go to Windows Services on the slave -- StartMenu, type "services"
Select the Jenkins Slave service in the list on the right
Right-click and select "Properties" of the Jenkins Slave service
Select the "Log On" tab
Update the username and password used in manual tests
    Domain login can be specificied with <DOMAIN>\<USERNAME>
    Local logins just use <USERNAME>
OK to save and exit
Right-click again and select "Restart" to make the changes active.
like image 29
dhj Avatar answered Oct 24 '22 10:10

dhj


I found a decent workaround in my case. The git clone command always inherits its process owner, which may make a difference, even if the two owners of Jenkins (SYSTEM) and cmd (USER) seem to have the same rights on your system. All other configurations were identical (keys, knownhosts, Git client version).

So as far as I can see, calling git clone from cmd will succeed because it calls the remote as USER, whereas git clone called from Jenkins may be rejected because it calls the remote as SYSTEM. In Services, where you would typically start Jenkins through the GUI, you can configure the service to run as a different user (right click on service --> Properties --> Log On). I had to put it like USER@DOMAIN, e.g. [email protected] or so. I'm not sure about how a cmd parameter would look, but I'd expect there to be one.

Also, I don't quite know what difference this workaround makes in the end, because on my Jenkins, SYSTEM and USER are configured to have the same rights across the system and they are of course both recognized as "Jenkins" by remote. Still, it does the trick for me. Deeper insights welcome.

like image 45
Sir Jane Avatar answered Oct 24 '22 10:10

Sir Jane