Why is Jenkins getting Authentication Failed error for git submodule update?
Asked Answered
U

5

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?

Uranyl answered 14/6, 2013 at 2:4 Comment(5)
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 failedLigroin
@PatrickClancey, does that merit a question up vote? :)Uranyl
Do you have the same protocol specified for the submodule? Not cloning your repo with https:// but using git:// for the submodule?Siglos
@Siglos - 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.Uranyl
See Jenkins: Retrieving submodules with GitMchenry
J
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.

Jointly answered 15/5, 2017 at 4:1 Comment(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..."Knipe
Thank you for this "Note that the repository cloning protocols must be the same..", good man!Avilla
I confirm that the protocols must match :)Venessavenetia
B
0

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

Bulger answered 29/7, 2013 at 9:24 Comment(0)
P
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%

Palaeozoology answered 16/1, 2016 at 14:4 Comment(0)
R
0

git config --global credential.helper wincred

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

Readytowear answered 24/6, 2016 at 21:38 Comment(1)
Instead of posting links as answer add some text to explanation how this answer help to OP in fixing current issue.ThanksStewardson
P
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.

Phone answered 19/5, 2020 at 13:29 Comment(1)
This was my issue: superproject repo URL git@git.../repo.git in Jenkins but https://.../repo.git in .gitmodules.Cholecyst

© 2022 - 2024 — McMap. All rights reserved.