简体   繁体   English

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

[英]git plugin in Jenkins on Windows does not use credentials with submodule

I have an issue with Jenkins on Windows with git, I can use ssh credentials to fetch git repository from BitBucket but when it tries to fetch the submodule repository, which is on the same account, I get permission exception. 我在Windows上使用git与Jenkins有问题,我可以使用ssh凭据从BitBucket获取git存储库,但是当它尝试获取同一帐户上的子模块存储库时,我获得了权限异常。

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

C:\\CI\\Git\\bin\\git.exe --version using GIT_SSH to set credentials Bitbucket key 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}" Checking out Revision 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 remote C:\\CI\\Git\\bin\\git.exe submodule init C:\\CI\\Git\\bin\\git.exe submodule sync C:\\CI\\Git\\bin\\git.exe config --get remote.origin.url C:\\CI\\Git\\bin\\git.exe submodule update FATAL: Command "C:\\CI\\Git\\bin\\git.exe submodule update" returned status code 1: stdout: stderr: Cloning into 'include/portal_air'... Permission denied (publickey). 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)。 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

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)

Yes, This is an issue which i have faced to clone a project and its sub module. 是的,这是克隆项目及其子模块时遇到的问题。

I was using https instead of git@ to clone the repos, git scm plugin only apply the credential passed via jenkins to main module and not for sub module. 我使用https代替git @来克隆repos,git scm插件只将通过jenkins传递的凭据应用到主模块而不是子模块。 To fix the issue i had to run a process which stores the credential and passes it to any git operation which need authentication. 要解决这个问题,我必须运行一个存储凭证的进程,并将其传递给任何需要身份验证的git操作。 Like this http://www.scmtechblog.net/2014/12/git-authentication-for-automation-script.html 像这样http://www.scmtechblog.net/2014/12/git-authentication-for-automation-script.html

Now, you are trying to access via git@ and still getting permission denied, Can you please make sure that the account has correct access on submodule repository for which you added the ssh keys. 现在,您正尝试通过git @访问并仍然获得权限被拒绝,您能否确保该帐户对您添加了ssh密钥的子模块存储库具有正确的访问权限。

Submodule authentication using the same credentials and protocol as the parent repository are now support with the Jenkins git plugin. 使用与父存储库相同的凭据和协议的子模块身份验证现在支持Jenkins git插件。 Support was added in the 10 Sep 2016 release of Jenkins git plugin 3.0.0. 2016年9月10日发布的Jenkins git插件3.0.0中添加了支持。

The submodule configuration portion of the job definition page ("Additional Behaviours" > "Advanced Sub-modules Behaviours") "now 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 that the repository cloning protocols must be the same (ssh or https) for the parent repository and the submodules, otherwise the parent credentials can't be used with the submodule repository. 请注意,父存储库和子模块的存储库克隆协议必须相同(ssh或https),否则父凭据不能与子模块存储库一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM