Git Jenkins Linux slave无法获取子模块

Git Jenkins Linux slave无法获取子模块,git,jenkins,Git,Jenkins,我正在使用Jenkins和Github Enterprise配置CI构建。源代码是在SSH之上的。存储库包括子模块。由于GitHub不允许将部署密钥分配给多个存储库,因此我生成了两对SSH密钥,并将它们添加到主repo和子模块中 我的詹金斯工作是一个自由式的工作(实际上,它是一个矩阵构建,但它似乎并不重要) 问题是:如果作业配置中打开了ssh代理插件,Linux机器上的git插件将收到“拒绝公钥权限”错误 如果我在buildenvironment部分中取消选中ssh-agent,git将成功提取

我正在使用Jenkins和Github Enterprise配置CI构建。源代码是在SSH之上的。存储库包括子模块。由于GitHub不允许将部署密钥分配给多个存储库,因此我生成了两对SSH密钥,并将它们添加到主repo和子模块中

我的詹金斯工作是一个自由式的工作(实际上,它是一个矩阵构建,但它似乎并不重要)

问题是:如果作业配置中打开了
ssh代理
插件,Linux机器上的git插件将收到“拒绝公钥权限”错误

如果我在buildenvironment部分中取消选中
ssh-agent
,git将成功提取代码并启动构建。但是,我需要这个代理,因为构建的一部分有时包括尝试运行
git merge
命令

另一个Jenkins作业,使用相同的配置、相同的git凭据,启用了
ssh agent
,但绑定到Windows10机器,可以很好地提取代码。Windows PC运行的git版本与Linux PC相同

以下是作业配置的屏幕截图:

以下是生成日志:

Running as SYSTEM
[EnvInject] - Loading node environment variables.
[EnvInject] - Preparing an environment for the build.
[EnvInject] - Keeping Jenkins system variables.
[EnvInject] - Keeping Jenkins build variables.
[EnvInject] - Executing and processing the following script content: 
# rsync test data

[/jenkins] $ /bin/bash -xe /tmp/jenkins8963773223071803410.sh
+ # rsync test data
[EnvInject] - Script executed successfully.
[EnvInject] - Injecting as environment variables the properties content 
tmpfs_path=/mnt/tmp/tmpfs
GIT_TRACE=1
tmpfs_root=/mnt/tmp

[EnvInject] - Variables injected successfully.
[EnvInject] - Injecting contributions.
Building remotely on linuxbuilder (build android linux) in workspace /jenkins/workspace/folder/job_linux
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent]   Exec ssh-agent (binary ssh-agent on a remote machine)
$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-riGv3o6NzZwu/agent.38165
SSH_AGENT_PID=38168
[ssh-agent] Started.
Running ssh-add (command line suppressed)
Identity added: /jenkins/workspace/folder/job_linux@tmp/private_key_4751335150532655093.key (/jenkins/workspace/folder/job_linux@tmp/private_key_4751335150532655093.key)
[ssh-agent] Using credentials jenkins (public deploy key 1 (openssh))
Running ssh-add (command line suppressed)
Identity added: /jenkins/workspace/folder/job_linux@tmp/private_key_7973546765502126654.key (/jenkins/workspace/folder/job_linux@tmp/private_key_7973546765502126654.key)
[ssh-agent] Using credentials jenkins (public deploy key 2 (openssh))
The recommended git tool is: NONE
using credential 6cf33517-d541-478f-9dd2-78dac281dca1
using credential jenkins_deploy_2
 > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from 2 remote Git repositories
 > /usr/bin/git config remote.origin.url git@github.corp:ORG/repository.git # timeout=10
Cleaning workspace
 > /usr/bin/git rev-parse --verify HEAD # timeout=10
Resetting working tree
 > /usr/bin/git reset --hard # timeout=10
 > /usr/bin/git clean -ffdx # timeout=10
Pruning obsolete local branches
Pruning obsolete local tags that do not exist on remotes
 > /usr/bin/git show-ref --tags -d # timeout=10
 > /usr/bin/git --version # timeout=10
 > git --version # 'git version 2.28.0'
using GIT_SSH to set credentials public deploy key 1 (openssh)
 > /usr/bin/git ls-remote -t -- git@github.corp:ORG/repository.git # timeout=10
using GIT_SSH to set credentials jenkins_deploy_2
 > /usr/bin/git ls-remote -t -- git@github.corp:ORG/submodule.git # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from git@github.corp:ORG/repository.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:996)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1237)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1297)
    at hudson.scm.SCM.checkout(SCM.java:505)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1206)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
    at hudson.model.Run.execute(Run.java:1894)
    at hudson.matrix.MatrixBuild.run(MatrixBuild.java:323)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:428)
Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git ls-remote -t -- git@github.corp:ORG/submodule.git" returned status code 128:
stdout: 
stderr: 13:54:41.365528 git.c:444               trace: built-in: git ls-remote -t -- git@github.corp:ORG/submodule.git
13:54:41.365725 run-command.c:663       trace: run_command: unset GIT_PREFIX; /jenkins/workspace/folder/job_linux@tmp/jenkins-gitclient-ssh530831427594629327.sh-copy git@github.corp 'git-upload-pack '\''ORG/submodule.git'\'''
ERROR: Permission to ORG/submodule.git denied to deploy key
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1951)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1942)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getRemoteReferences(CliGitAPIImpl.java:3381)
    at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:936)
    at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:909)
    at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:860)
    at hudson.remoting.UserRequest.perform(UserRequest.java:211)
    at hudson.remoting.UserRequest.perform(UserRequest.java:54)
    at hudson.remoting.Request$2.run(Request.java:375)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:73)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
    Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to IrisCI_linuxbuilder
        at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1800)
        at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357)
        at hudson.remoting.Channel.call(Channel.java:1001)
        at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:286)
        at com.sun.proxy.$Proxy80.getRemoteReferences(Unknown Source)
        at org.jenkinsci.plugins.gitclient.RemoteGitImpl.getRemoteReferences(RemoteGitImpl.java:566)
        at hudson.plugins.git.extensions.impl.PruneStaleTag.decorateFetchCommand(PruneStaleTag.java:112)
        at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:992)
        at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1237)
        at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1297)
        at hudson.scm.SCM.checkout(SCM.java:505)
        at hudson.model.AbstractProject.checkout(AbstractProject.java:1206)
        at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
        at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
        at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
        at hudson.model.Run.execute(Run.java:1894)
        at hudson.matrix.MatrixBuild.run(MatrixBuild.java:323)
        at hudson.model.ResourceController.execute(ResourceController.java:97)
        at hudson.model.Executor.run(Executor.java:428)
ERROR: Error fetching remote repo 'origin'