Jenkins git submodule update fails

时光总嘲笑我的痴心妄想 提交于 2019-12-04 00:57:56

This is was a known bug in jenkins: https://issues.jenkins-ci.org/browse/JENKINS-20941 but it has now been fixed, update your Git plugin to resolve the issue.

If updating is not possible, as a workaround, you could put the key in jenkins-users .ssh folder.

Based on the earlier answers here, I re-prioritized upgrading my client's Jenkins. Now they are on Jenkins 2.41 with Git plugin 3.0.1 and before additional configuration this did not fix the issue. I found the configuration to be a little tricky:

  1. Add top-level repository to Source Code Management -> Git
  2. Select the "Additional Behaviours" Add button
    • Select "Advanced sub-modules behaviours"
  3. I tested with only "Recursively update submodules" and got the "Permission denied" error (see bottom*)
  4. However, I now select both "Recursively update submodules" and "Use credentials from default remote of parent repository" in Jenkins 2.41

Once I select both options, it uses the credentials I had configured for the top-level repository and everything works for me. Here is what the dialog looks like in 2.41 with Git plugin 3.0.1:

* Here is the essence of my "Permission denied" error:

Cloning into 'thirdparty'...

stderr: Permission denied (publickey). fatal: The remote end hung up unexpectedly Clone of 'ssh://hg@bitbucket.org//thirdparty' into submodule path 'thirdparty' failed

PS Just before posting, I did my usual double check to make sure I'm not duplicating an answer. In this case, I see that @danielfn's comment points to something that is nearly identical to my answer, but 1. this didn't help me and I ended up figuring it out by trial and error and 2. it is StackOverflow policy to post answers here rather than referencing external links.

As an alternative, you may use 'Source Code Management' - 'Multiple SCMs' to manually configure all the sub-modules and add 'Additional Behaviours' - 'Check out to a sub-directory' for each one.

It seems that they have fixed it with the versions git client plugin 1.20.0-beta1 and git plugin 2.5.0-beta1. However, they can only be added to Jenkins by specifying to pull updates from the experimental update center.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!