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

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.dtcms.com/a/232184.html

相关文章:

  • DAY 22 复习日
  • java--静态方法和非静态方法的调用
  • 从 Stdio 到 HTTP SSE,在 APIPark 托管 MCP Server
  • Windows系统下Cursor与QWQ-32B大模型的本地部署及插件调用实现方法
  • Spring Boot 启动流程及配置类解析原理
  • Monorepo架构: Nx Cloud 扩展能力与缓存加速
  • Hive的Parquet格式优化方法
  • 【项目实践】SMBMS(Javaweb版)(三)登出、注册、注销、修改
  • Spring事务失效-----十大常见场景及解决方案全解析
  • PHP 8.5 即将发布:管道操作符、强力调试
  • npm run dev 报错:Error: error:0308010C:digital envelope routines::unsupported
  • HttpServletRequest常用方法
  • WINDOWS端口关闭工具
  • Java转Go日记(六十):gin其他常用知识
  • NLP学习路线图(二十五):注意力机制
  • 宠物空气净化器哪个好用?2025宠物空气净化器测评:352、希喂、有哈
  • Golang——9、反射和文件操作
  • npm install 相关命令
  • 【Oracle】分区表
  • HarmonyOS:Counter计数器组件
  • 在Docker里面运行Docker
  • [10-1]I2C通信协议 江协科技学习笔记(17个知识点)
  • AWS Elastic Beanstalk + CodePipeline(Python Flask Web的国区CI/CD)
  • [Git] 分布式版本控制 远程仓库协作
  • 一次Oracle的非正常关闭
  • npm install 报错:npm error: ...node_modules\deasync npm error command failed
  • 【p2p、分布式,区块链笔记 MESH】Bluetooth蓝牙通信拓扑与操作 BR/EDR(经典蓝牙)和 BLE
  • 数据库优化实战分享:高频场景下的性能调优技巧与案例解析
  • Java转Go日记(五十九):参数验证
  • 自建 Derp 中继节点