Windows上Jenkins的git插件不使用带子模块的凭据

Ido*_*Ran 5 git git-submodules jenkins

我在Windows上使用git与Jenkins有问题,我可以使用ssh凭据从BitBucket获取git存储库,但是当它尝试获取同一帐户上的子模块存储库时,我获得了权限异常.

从git@bitbucket.org获取上游更改:mycomp/at.git

C:\ CI\Git\bin\git.exe - 使用GIT_SSH设置凭证Bitbucket密钥C:\ CI\Git\bin\git.exe fetch --tags --progress git@bitbucket.org:mycomp/at .git + refs/heads/:refs/remotes/origin / C:\ CI\Git\bin\git.exe rev-parse"origin/ci ^ {commit}"签出修订版a079842300ba7fc9e6f4e7182c94af2cfc3af0ba(origin/ci)C:\ CI\Git\bin\git.exe config core.sparsecheckout C:\ CI\Git\bin\git.exe checkout -f a079842300ba7fc9e6f4e7182c94af2cfc3af0ba C:\ CI\Git\bin\git.exe rev-list a079842300ba7fc9e6f4e7182c94af2cfc3af0ba C:\ CI\Git\bin\git.exe远程C:\ CI\Git\bin\git.exe子模块init C:\ CI\Git\bin\git.exe子模块同步C:\ CI\Git\bin\git.exe config - -get remote.origin.url C:\ CI\Git\bin\git.exe子模块更新FATAL:命令"C:\ CI\Git\bin\git.exe submodule update"返回状态码1:stdout:stderr:Cloning进入'include/portal_air'...权限被拒绝(publickey).致命:无法从远程存储库读取.

Please make sure you have the correct access rights
and the repository exists.
Clone of 'git@bitbucket.org:mycomp/portal_air.git' into submodule path 'include/portal_air' failed

hudson.plugins.git.GitException: Command "C:\CI\Git\bin\git.exe submodule update" returned status code 1:
stdout: 
stderr: Cloning into 'include/portal_air'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Clone of 'git@bitbucket.org:mycomp/portal_air.git' into submodule path 'include/portal_air' failed

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1406)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:87)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$6.execute(CliGitAPIImpl.java:741)
    at hudson.plugins.git.extensions.impl.SubmoduleOption.onCheckoutCompleted(SubmoduleOption.java:77)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:908)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1414)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:671)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:580)
    at hudson.model.Run.execute(Run.java:1684)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:231)
Run Code Online (Sandbox Code Playgroud)

vis*_*dhe 3

是的,这是我在克隆项目及其子模块时遇到的问题。

我使用 https 而不是 git@ 来克隆存储库,git scm 插件仅将通过 jenkins 传递的凭据应用于主模块,而不应用于子模块。为了解决这个问题,我必须运行一个进程来存储凭据并将其传递给任何需要身份验证的 git 操作。像这样 http://www.scmtechblog.net/2014/12/git-authentication-for-automation-script.html

现在,您尝试通过 git@ 访问,但权限仍然被拒绝,您能否确保该帐户对您添加了 ssh 密钥的子模块存储库具有正确的访问权限。