我们的项目存储库非常大(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
}
}
如果克隆次数减少,那将是非常有益的。在执行行 checkout (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可能会解决这个问题。但我不知道脚本管道中的语法。
3条答案
按热度按时间pxq42qpu1#
你可以在 checkout 之前在
scm
对象中启用一个浅克隆(没有历史记录,只获取最近的提交):但是,我建议您建立并维护一个参考存储库,这在数量级上会更快:
1.在终端窗口中将存储库克隆到镜像中。此仓库将仅包含git对象:
1.在Jenkins中创建一个新作业,定期更新镜像存储库。更新镜像时仅使用
fetch
命令:1.告诉
scm
对象使用镜像存储库作为引用。在读取引用之后,远程存储库会被查询以获取新的提交,所以你不必担心镜像总是保持最新:在设置之后,您将看到您的整个存储库在几秒钟内被克隆,而且您还可以保留所有存储库的历史记录。如果从步骤1中创建的镜像存储库手动克隆,则可以自行测试克隆:
关于修改默认
scm
对象的注意事项:如果您不想更改它,您可以创建一个新的对象,如this answer所示:mbyulnm02#
credentialId
可以通过点击http://yourjenkinsinstall/credentials找到irtuqstp3#
根据towel的回答,你也可以通过在扩展名CloneOption中添加参数noTags来避免git仓库中的所有标签,这里是checkout对象的外观:
以下是文档:
noTags:boolean取消选择此选项将执行不带标记的克隆,当您只想访问refspec指定的内容时,可以节省时间和磁盘空间。
友情链接:https://www.jenkins.io/doc/pipeline/steps/params/gitscm/