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?

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 failed Commented Jun 14, 2013 at 14:52
  • @PatrickClancey, does that merit a question up vote? :) Commented Jun 17, 2013 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? Commented Jan 6, 2014 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. Commented Oct 8, 2014 at 16:11
  • See Jenkins: Retrieving submodules with Git Commented Feb 18, 2015 at 15:45

6 Answers 6

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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..."
Thank you for this "Note that the repository cloning protocols must be the same..", good man!
I confirm that the protocols must match :)
0

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

Comments

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%

Comments

0

git config --global credential.helper wincred

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

1 Comment

Instead of posting links as answer add some text to explanation how this answer help to OP in fixing current issue.Thanks
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.

1 Comment

This was my issue: superproject repo URL git@git.../repo.git in Jenkins but https://.../repo.git in .gitmodules.
0

I am really sorry for necro posting. But for the future visitors. If you are pulling the Main repo (that repo contains a submodule) using ssh, if your .gitmodule file's url set to [https:]//xxxxxx/foo.git jenkins won't be able authenticate and build will be failed. So you should update your url under the .gitmodule file with ssh url.

If you are face any authentication problems please go to [http://]yourjenkins.com -> manage jenkins -> security and find "Git Host Key Verification Configuration" and be sure that it is set to Accept First connection

Here is the visual guide

and if you still facing the issue please go to /var/jenkins_home/workspace/YOUR_JOB_NAME and check for pulled repo

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.