4

I have installed jenkins on my centos7 server and tried to build a maven build. Created a new maven build job and in SCM I was trying to pull the code from github but it showed me an error like...

Failed to connect to repository : Command "git ls-remote -h https://github.com/example.git HEAD" returned status code 128: stdout:  stderr: remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/example.git/'

And also I setup an SSH public keys to my github. I don't know how to solve this. Anyone help me.Thanks in advance.

Naveen Kumar R B
  • 6,248
  • 5
  • 32
  • 65
User
  • 189
  • 3
  • 4
  • 14
  • Try this: https://stackoverflow.com/questions/46893328/bitbucket-access-keys-can-only-be-used-for-read-only/55469070#55469070 – Remigiusz Apr 02 '19 at 07:35

1 Answers1

1

also I setup an SSH public keys to my github

That would have zero impact on an HTTPS URL: the SSH key is ignored.

Check if you havbe a git credential helper in place which might cache your credentials (GitHub username/password)

git config credential.helper

For instance, it could be 'cache'.

I would recommend (as in this answer) to set it to gnome-keyring:

git config --global credential.helper gnome-keyring

Then try again your git ls-remote, from command-line:

git ls-remote https://<yourUsername>@github.com/<yourUsername>/<yourRepo.git>

That should prompt for your GitHub username/password. Once entered, a second git ls-remote should not ask again for your credentials.

From there, an SCM process from your Jenkins, as long as said Jenkins runs with your account, should work.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250