10

I have a Jenkins job that pulls from a BitBucket repo that was working fine, and still is. However, I've added a submodule and Jenkins is choking on that. Here is a clip from the Jenkins console output:

FATAL: Command "C:\Program Files (x86)\Git\cmd\git.exe submodule update" returned status code 1: stdout: Cloning into 'submodules/my.repo'...

stderr: fatal: Authentication failed

I'm using an ssh key which I added to my deployment keys for the main repo in BitBucket. And that's always worked. I added the same key to my submodule repo's deployment keys. Can anyone tell me why authentication is failing?

Sean
  • 8,407
  • 3
  • 31
  • 33
  • I have exactly the same issue using GitHub, build was working fine, but now fails after adding a submodule. I get FATAL: Command "/usr/bin/git submodule update" returned status code 1: stdout: stderr: fatal: Authentication failed – Patrick Clancey Jun 14 '13 at 14:52
  • @PatrickClancey, does that merit a question up vote? :) – Sean Jun 17 '13 at 16:46
  • 1
    Do you have the same protocol specified for the submodule? Not cloning your repo with https:// but using git:// for the submodule? – riezebosch Jan 06 '14 at 12:58
  • @riezebosch - Unfortunately this was a project for a company that I stopped working for before your post and I don't recall the details to answer your question. But I do know for a fact that I've seen that inconsistency be an issue with regard to authentication. So for anybody reading, they should check that. – Sean Oct 08 '14 at 16:11
  • See [Jenkins: Retrieving submodules with Git](http://stackoverflow.com/a/28587627/1164966) – Benoit Blanchon Feb 18 '15 at 15:45

5 Answers5

6

Versions of the Jenkins git plugin prior to 3.0.0 did not support submodule authentication. Submodule authentication using the same credentials and protocol as the parent repository are now supported with the Jenkins git plugin. Support was added in the 10 Sep 2016 release of Jenkins git plugin 3.0.0.

The submodule configuration portion of the job definition page ("Additional Behaviours" > "Advanced Sub-modules Behaviours") includes a checkbox "Use credentials from default remote of parent repository". Check that box and the credentials from the parent repository will be used for the submodules.

Note: the repository cloning protocols must be the same (ssh or https) for the parent repository and all the submodules, otherwise the parent credentials can't be used with the submodule repository.

Mark Waite
  • 1,351
  • 11
  • 13
  • 3
    Thanks!! This saved my day: "Note that the repository cloning protocols must be the same (ssh or https) for the parent repository and the submodules..." – fsteff Mar 28 '19 at 13:04
  • Thank you for this "Note that the repository cloning protocols must be the same..", good man! – emedentsii May 14 '20 at 17:36
  • I confirm that the protocols must match :) – kicaj Aug 26 '20 at 13:05
0

Try to copy the /.shh folder into your Jenkins home directory.

Johnny Chen
  • 2,025
  • 1
  • 18
  • 27
0

I faced this issue, with Jenkins Slave (executed as Windows Service). I solved it by deploying Jenkins SSH key in the .ssh directory of the SYSTEM user:

C:\Windows\SysWOW64\config\systemprofile\.ssh\

SYSTEM home directory varies depending on OS version and setup. To identify it just echo env. var. %USERPROFILE%

Destroyica
  • 4,147
  • 3
  • 33
  • 50
0

git config --global credential.helper wincred

https://help.github.com/articles/caching-your-github-password-in-git/#platform-windows

Johnny Cage
  • 5,526
  • 2
  • 11
  • 7
0

Additional to above answers, I realized that I'm using https urls of the submodules in my main repo, so I had to change my submodule url's https to ssh in main git repo.

Emre Akcan
  • 982
  • 10
  • 27