git clone without history using SCM

时光毁灭记忆、已成空白 提交于 2019-12-11 01:07:55

问题


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

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

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

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.

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


回答1:


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
    ])
}

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.



来源:https://stackoverflow.com/questions/56870219/git-clone-without-history-using-scm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!