Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Local Jenkins can't authenticate remote Gitlab private repository

I installed Jenkins on windows with all addons that I need, I think so. When i create a new job and in Repository URL i write my url

http://git.*****.org/*****/seleniumproject.git

and it shows

Help for feature: Repository URL
Failed to connect to repository : Command "C:\Program Files (x86)\Git\bin\git.exe ls-remote -h http://git.*****.org/*****/seleniumproject.git HEAD" returned status code 128:
stdout:
stderr: fatal: Authentication failed for 'http://git.*****.org/*****/seleniumproject.git'`

My question: how can I authenticate to my remote gitlab?! I have folder with .ssh with all keys but don't know what to do...

Update: strange because my TortoiseGit is working perfectly

My Fix :

  1. Go to jenkins path and save .ssh folder in root example C:\Jenkins\.ssh .ssh folder u can find in C:\Users\yourname\.ssh
  2. Go to Jenkins > Manage Jenkins > Manage Credentials, here you can add your private key or select from the jenkins master !/.ssh
  3. Go to Jenkins > Manage Jenkins > Configure System in git executable wrote this C:\Program Files (x86)\Git\cmd\git.exe path must be with cmd
  4. Create new job and in repository url add ssh://[email protected]:/name/projet.git
like image 890
Andrian Durlestean Avatar asked Sep 05 '13 12:09

Andrian Durlestean


3 Answers

My Fix :

  1. Go to jenkins path and save .ssh folder in root example C:\Jenkins.ssh .ssh folder u can find in C:\Users\yourname.ssh
  2. Go to Jenkins > Manage Jenkins > Manage Credentials, here you can add your private key or select from the jenkins master !/.ssh
  3. Go to Jenkins > Manage Jenkins > Configure System in git executable wrote this C:\Program Files (x86)\Git\cmd\git.exe path must be with cmd
  4. Create new job and in repository url add ssh://[email protected]:/name/projet.git
like image 140
Andrian Durlestean Avatar answered Sep 24 '22 11:09

Andrian Durlestean


I have folder with .ssh with all keys

Those keys won't never been read, if you keep using an http(s) url.

You should use an ssh url, and first make sure that this works properly:

ssh -Tv ssh://git@git.*****.org

(assuming the user account you need on the server side is 'git')


Note that the section on SSH of this guide is of interest here:

you have installed TortoiseGIT

http://guides.beanstalkapp.com/version-control/git-on-windows/git-ssh-variable.png

If you have ever installed TortoiseGit on the computer you’re setting up your keys on, you may encounter problems.
TortiseGit creates an environment variable that configures Plink as your SSH keystore, which may conflict when you try to use Git and SSH.
No matter how you change your config or uninstall TortoiseGit, that environment variable persists and until you delete it, Git will not look to your regular .ssh directory to find the proper key.

In our case environment variable looked like this:

GIT_SSH=c:\Program Files\Putty\plink.exe. 

Environment variables can be found here:

  • Windows XP: Control Panel → System Properties → Advanced → Environment variables
  • Windows 7: Control Panel → System → Advanced system settings → Environment variables
like image 21
VonC Avatar answered Sep 23 '22 11:09

VonC


Try using C:\Program Files (x86)\Git\cmd\gitk.cmd instead of \bin\git.exe. If not solved, then Here is information how to configure ssh. Sometimes you may also get public key error, which is solved here. If you want to generate new ssh keys, this article will help you.

like image 42
Digeek Avatar answered Sep 22 '22 11:09

Digeek