git - Jenkins 管道 git 命令子模块更新

标签 git jenkins jenkins-pipeline

我想在 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/

相关文章:

git - 是否可以在 BitBucket 上获取原始文件?

git - 如何有效地查看 git 下维护的重命名文件的内容?

Jenkins Permission Denied 中的 GIT 克隆问题

git - Jenkins - 一个版本有多少 CI/CD 管道?

jenkins - 在 jenkins 管道脚本中获取 gradle 变量

jenkins - Jenkins 2 Pipeline 中的 Sonar - 缺少全局配置

git - 忽略的文件在“提交更改”窗口中仍然可见 - IntelliJ 13

Git "Live Server"最佳实践

ios - Jenkins 和 CocoaPods

intellij-idea - Jenkinsfile DSL 源代码