git无历史记录使用SCM [英] git clone without history using SCM

查看:106
本文介绍了git无历史记录使用SCM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的项目非常庞大,我们希望避免克隆所有git历史记录.

Our project is huge and we would like to avoid cloning all git history.

是否可以在詹金斯中使用checkout scm通过git clone传递depth=1?

Is it possible to git clone passing depth=1 using checkout scm in Jenkins?

如果可能,我找不到任何有关如何配置SCM或如何传递参数的文档.

I cannot find any documentation about how to configure SCM or how to pass arguments, if possible.

已添加:
找到了文档

Added:
Found the documentation

https://jenkins.io/doc/pipeline/steps/workflow-scm-step/#code-checkout-code-general-scm

类型:int
深度(可选)
设置浅克隆深度,以便git只会下载最近的历史记录 专案,只需要存取最新的档案,即可节省时间和磁碟空间 版本库.

Type: int
depth (optional)
Set shallow clone depth, so that git will only download recent history of the project, saving time and disk space when you just want to access the latest version of a repository.

,但尚不清楚如何将其传递给checkout scm

but it's not clear how to pass it to checkout scm

推荐答案

如果您使用脚本化管道,则可以自定义checkout scm使其看起来或多或少像这样:

If you use scripted pipeline then you can customize checkout scm to look more or less like this:

node {
    checkout([
        $class: 'GitSCM',
        branches: scm.branches,
        doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
        extensions: scm.extensions,
        userRemoteConfigs: scm.userRemoteConfigs,
        depth: 1
    ])
}

如果使用声明性管道,则需要转到管道作业配置,并且在行为部分中,需要添加 Git->高级克隆行为,然后标记浅克隆,并将浅克隆深度设置为1.

If you use the declarative pipeline, then you need to go to your pipeline job configuration and in the Behaviors section you need to add Git -> Advanced clone behaviors and mark Shallow clone and set Shallow clone depth to 1.

这篇关于git无历史记录使用SCM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆