我有一个包含子模块的存储库.这些是在可公开访问的GitHub存储库中开发的.然而,我的最终部署是在GitLab中使用镜像GitHub repos的断开连接的环境中,这些都需要身份验证.
我的.gitmodules文件包含公开可用的回购的网址.我sed在工作中做了一些替换并且可以正确地更新它们,但不幸的是,我当时无法进行身份验证,因为它是与git url:....步骤分开的操作.
我可以克隆项目:
git url: "git@my.gitlab.secure", branch: "master", credentialsId: "somecredentialid"
Run Code Online (Sandbox Code Playgroud)
不幸的是,这不会更新我的子模块.因为我需要身份验证.
我也可以用以下方法克隆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']]
])
}
}
Run Code Online (Sandbox Code Playgroud)
我不清楚文档中的内容doGenerateSubmoduleConfigurations: true,和submoduleCfg:用途.
我觉得checkout方式可能是解决方案,但我无法弄清楚如何更新.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']]
]
Run Code Online (Sandbox Code Playgroud)