如何在脚本化管道中指定检出深度(scm)

问题描述 投票:2回答:1

我们的项目存储库很大(2.5GB)。因此,在脚本化管道中的checkout(scm)步骤中,从GIT克隆代码需要更长的时间。并且由于GIT试图获取整个历史记录,我们面临以下错误。

到目前为止,我已经尝试过使用checkout(scm),我读了https://jenkins.io/doc/pipeline/steps/workflow-scm-step/有一个名为depth的选项,通过该选项我们可以仅下载最近的提交。

但是我不知道它的语法。

node(nodeName) {
    try {
    deleteDir()
    checkout(scm)
        ....
        ....
    }
    catch(Exception ex) {
        throw ex
    }    
}

如果克隆时间减少,那将是非常有益的。执行行结帐(scm)后,

我们有时会出现以下错误。

using credential Servicejenkins_build
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository 
hudson.plugins.git.GitException: Command "C:\Git\cmd\git fetch --no-tags --progress https://gitlab.com/../../supportforpc.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: remote: Enumerating objects: 1           
remote: Enumerating objects: 24671, done.        
remote: Counting objects:   0% (1/24671)           
remote: Counting objects:   1% (247/24671)           
remote: Counting objects:   2% (494/24671)           
remote: Counting objects:   3% (741/24671)           
remote: Counting objects:   4% (987/24671)           
remote: Counting objects:   5% (1234/24671)           
remote: Counting objects:   6% (1481/24671)  
.....
....
Counting objects:   100% (24671/24671) 
remote: Compressing objects:   0% (1/10279)           
remote: Compressing objects:   1% (103/10279)           
remote: Compressing objects:   2% (206/10279)           
remote: Compressing objects:   3% (309/10279)           
remote: Compressing objects:   4% (412/10279)           
remote: Compressing objects:   5% (514/10279)           
remote: Compressing objects:   6% (617/10279)           
remote: Compressing objects:   7% (720/10279)           
remote: Compressing objects:   8% (823/10279)           
remote: Compressing objects:   9% (926/10279)           
remote: Compressing objects:  10% (1028/10279) 
....
....
remote: Compressing objects:  100% (10279/10279) 
Receiving objects:   0% (1/24671)   
Receiving objects:   1% (247/24671)   
Receiving objects:   2% (494/24671)   
Receiving objects:   3% (741/24671)   
Receiving objects:   4% (987/24671)   
Receiving objects:   5% (1234/24671)   
Receiving objects:   6% (1481/24671)
....
....
Receiving objects:   43%

    fatal: index-pack failed
    error: RPC failed; curl 56 SSL read: 
    error:00000000:lib(0):func(0):reason(0), errno 10054

因此,我认为,在checkout(scm)中使用深度1可能会解决此问题。但是我不知道脚本化管道中的语法。

jenkins jenkins-pipeline jenkins-groovy
1个回答
0
投票

您可以在结帐前在scm对象中启用浅表克隆(无历史记录,并且仅提取最近的提交:

© www.soinside.com 2019 - 2024. All rights reserved.