我有一个包含子模块的存储库。这些是在可公开访问的 GitHub 存储库中开发的。然而,我的最终部署是在一个断开连接的环境中,GitLab 中有镜像的 GitHub 存储库,所有这些都需要身份验证。
我的 .gitmodules
文件包含公开可用存储库的 URL。我做了一些sed
在工作中替换并可以正确更新它们,但不幸的是,我无法进行身份验证,因为它是与 git url:....
不同的操作步。
我可以克隆项目:
git url: "git@my.gitlab.secure", branch: "master", credentialsId: "somecredentialid"
不幸的是,这并没有更新我的子模块。而且因为我需要身份验证。
我也可以使用
checkout
进行克隆: 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']]
])
}
}
我不清楚 documentation什么
doGenerateSubmoduleConfigurations: true,
和 submoduleCfg:
是给。我觉得
checkout
方式可能是解决方案,但我不知道如何更新 .gitmodules
以反射(reflect)子模块的安全 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']]
]
关于git - Jenkins 管道子模块身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44978903/