Git Jenkins管道子模块身份验证
我有一个包含子模块的存储库。这些都是在可公开访问的GitHub存储库中开发的。然而,我的最终部署是在一个断开连接的环境中,GitLab中有镜像的GitHub repo,所有这些都需要身份验证 我的Git Jenkins管道子模块身份验证,git,jenkins,Git,Jenkins,我有一个包含子模块的存储库。这些都是在可公开访问的GitHub存储库中开发的。然而,我的最终部署是在一个断开连接的环境中,GitLab中有镜像的GitHub repo,所有这些都需要身份验证 我的.gitmodules文件包含公开可用回购协议的URL。我在作业中做了一些sed替换,可以正确地更新它们,但不幸的是,我无法进行身份验证,因为这是与git url:..步骤不同的操作 我可以通过以下方式克隆项目: git url: "git@my.gitlab.secure", branch: "mas
.gitmodules
文件包含公开可用回购协议的URL。我在作业中做了一些sed
替换,可以正确地更新它们,但不幸的是,我无法进行身份验证,因为这是与git url:..
步骤不同的操作
我可以通过以下方式克隆项目:
git url: "git@my.gitlab.secure", branch: "master", credentialsId: "somecredentialid"
不幸的是,这并没有更新我的子模块。因为我需要认证
我还可以使用签出
进行克隆:
checkout([
$class: 'GitSCM',
branches: [[name: 'master']],
doGenerateSubmoduleConfigurations: true,
extensions: [[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: true,
recursiveSubmodules: true,
reference: '', trackingSubmodules: true]],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'somecredentialid',
url: 'git@my.gitlab.secure']]
])
}
}
从数据生成子模块配置:true、
和子模块cfg:
的用途来看,我并不清楚
我觉得
签出
方式可能是解决方案,但我不知道如何更新.gitmodules
,以反映子模块的安全URL。在我的情况下,这对我很有效,与您在这里尝试的操作类似;看看这是否有帮助
checkout changelog: true, poll: true, scm: [
$class: 'GitSCM',
branches: [[name: "master"]],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'SubmoduleOption', recursiveSubmodules: true, parentCredentials: true], [$class: 'PruneStaleBranch']],
submoduleCfg: [],
userRemoteConfigs: [[name: 'origin', url: "Git ssh URL/${projectName}.git", credentialsId: 'Git credential']]
]
我的头也撞了一会儿,下面是我的发现
doGenerateSubmoduleConfigurations
被公开,这表明它调用了。那看起来根本不像你想要的。该选项可能应该是(a)在扩展中而不是核心插件中,(b)被称为doGenerateSubmoduleCombinationMatrix
或其他什么
submoduleCfg
在git插件中似乎没有太多明显的用途。我只找到了空的测试
功能似乎已经进入了新的阶段。这有一个方法onCheckoutCompleted(…)
,它调用git.submoduleUpdate(…)
因此,AFAICS类
子模块选项的扩展
项就是您想要的。而且文档有点特别。git@my.gitlab.secure
,这实际上是在使用ssh://
,也许你可以改为使用https://
,你的子模块url是什么样子的?它可以看起来像我想要的任何东西,现在.gitmodules
包含这样的条目:url=不考虑,这些必须更改为指向自托管安全存储库。