当前位置: 首页 > ai >正文

kubernetes jenkins pipeline优化拉取大仓库性能指定分支+深度

有时候我们历史的git仓库,提交了某个比较大的文件如果不限制 depth ,就会拉取所有的历史提交记录,这样在历史仓库比较大的时候 clone 非常之慢,而实际上我们只需要最新的代码来构建就行了,为了优化性能,我们可以配置指定拉取:

关键配置:

        stage('Check code') {echo("gitCommitId value is: ${gitCommitId}")// sh "sleep 10000"def scmVars = checkout([$class: 'GitSCM',branches: [[name: "${gitCommitId}"]],extensions: [[$class: 'CloneOption', depth: 1, shallow: true, noTags: true, honorRefspec: true, timeout: 3000]],userRemoteConfigs: [[credentialsId: "${gitlabCredential}",url: "${gitlabURL}",refspec: "+refs/heads/${gitCommitId}:refs/remotes/origin/${gitCommitId}"]]])commitHash = scmVars.GIT_COMMIT.take(8)echo("${commitHash}")}

上面的拉取方式只适合拉取分支的,如果还要兼容commitId,需要下面的配置:

// 判断是分支名还是 commit hash
def isCommitHash = gitCommitId ==~ /^[a-f0-9]{7,40}$/def scmVars = checkout([$class: 'GitSCM',branches: [[name: isCommitHash ? "${gitCommitId}" : "origin/${gitCommitId}"]],extensions: [[$class: 'CloneOption', depth: 1, shallow: true, noTags: true, honorRefspec: true, timeout: 3000]],userRemoteConfigs: [[credentialsId: "${gitlabCredential}",url: "${gitlabURL}",refspec: isCommitHash ? "+${gitCommitId}:refs/remotes/origin/target-commit" : "+refs/heads/${gitCommitId}:refs/remotes/origin/${gitCommitId}"]]
])
http://www.xdnf.cn/news/12034.html

相关文章:

  • 【物联网-S7Comm协议】
  • 快速用 uv 模拟发布一个 Python 依赖包到 TestPyPI 上,以及常用命令
  • scDown:单细胞RNA测序下游分析管道-文献精读140
  • Spring Boot+Neo4j知识图谱实战:3步搭建智能关系网络!
  • Win10停更,Win11不好用?现在Mac电脑比Win11电脑更便宜
  • 邮件多分类
  • Python基于历史模拟方法实现投资组合风险管理的VaR与ES模型项目实战
  • 【个人笔记】数据库原理(西电)
  • 使用 C/C++ 和 OpenCV 添加图片水印
  • 045-代码味道-数据泥团
  • 量子比特实现方式
  • 【Linux基础知识系列】第十一篇-Linux系统安全
  • 2025年低延迟业务DDoS防护全攻略:高可用架构与实战方案
  • 「数据分析 - NumPy 函数与方法全集」【数据分析全栈攻略:爬虫+处理+可视化+报告】
  • 如何基于Mihomo Party http端口配置git与bash命令行代理
  • Kafka 核心架构与消息模型深度解析(二)
  • graylog收集rsyslog实现搜索解析
  • Linux驱动:register_chrdev_region、 alloc_chrdev_region
  • Kaggle-Predicting Optimal Fertilizers-(多分类+xgboost)
  • 灵活控制,modbus tcp转ethernetip的 多功能水处理方案
  • 第二章 2.4 数据共享与使用之数据共享方式
  • 在 CentOS 上安装 Docker 和 Docker Compose 并配置使用国内镜像源
  • 仓库自动化搬运:自动叉车与AGV选型要点及核心技术解析
  • javaweb -html -CSS
  • uniapp微信小程序视频实时流+pc端预览方案
  • uniapp+<script setup lang=“ts“>解决有数据与暂无数据切换显示,有数据加载时暂无数据闪现(先加载空数据)问题
  • QObject::connect: Cannot queue arguments of type ‘xxx‘
  • 4.2 HarmonyOS NEXT分布式AI应用实践:联邦学习、跨设备协作与个性化推荐实战
  • Flask-SQLAlchemy使用小结
  • 学习路之php--性能优化