我想在 git clone 上更新子模块。
有没有办法用 Jenkins 管道 Git 命令来做到这一点?
目前我正在做这个...
git branch: 'master',
credentialsId: 'bitbucket',
url: 'ssh://bitbucket.org/hello.git'
它不会在克隆后更新子模块
最佳答案
git command因为管道步骤相当有限,因为它提供了更复杂的默认实现 checkout command .对于更高级的配置,您应该使用 checkout command ,您可以为其传递大量参数,包括所需的子模块配置。
你想要使用的可能是这样的:
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: false,
recursiveSubmodules: true,
reference: '',
trackingSubmodules: false]],
submoduleCfg: [],
userRemoteConfigs: [[url: 'your-git-server/your-git-repository']]])
根据文档,编写这些行通常很麻烦,我建议您改用 Jenkins 非常好的 Snippet Generator
(YourJenkins > yourProject > PipelineSyntax) 来自动生成 checkout 行!
关于git - Jenkins 管道 git 命令子模块更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42290133/