jenkins-pipeline - 如何在 jenkins groovy 中签出 SCM 的子目录?
问题描述
我有一个 git hub 存储库 ABC.git 它有以下目录 src ,config,env,test。我只想将 src 和 config 文件夹检出到我的 Jenkins 工作区中。
我可以使用 SCM 插件将完整的存储库签出到我的 jenkins 工作区中。
用于检查完整分支的命令:
checkout([
$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'CleanCheckout']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: '<gitCredentials>', url: '<gitRepoURL>']]
])
解决方案
使用它来检查特定目录/子目录:extensions: [[$class: 'SparseCheckoutPaths', sparseCheckoutPaths: [[path: '/directory/path/here']]]]
因此,您的脚本将如下所示:
checkout([
$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'CleanCheckout'],
[$class: 'SparseCheckoutPaths',
sparseCheckoutPaths: [[path: '/directory/path/here']]]],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: '<gitCredentials>', url: '<gitRepoURL>']]
])
推荐阅读
- css - display:none 被附加到上传到 Wordpress 的图像
- java - 如何杀死发送长时间运行的 HTTP 请求的线程?
- javascript - 计算数组中有多少具有特定名称的条目并保存以供以后使用
- python - Python - 根据条件分配值
- angular - 渐进式网络调用旧的网络托管应用程序
- vue.js - Vuex 双向可编辑绑定
- xamarin.forms - 使用 Azure AD B2C 为 Xamarin.iOS 配置 Entitlement.plist
- kubernetes - kubeadm 升级后块存储上的数据全部消失
- python - python中是否有通用的`str(int,base = n)`功能?
- isabelle - Isabelle:如何识别具有相同但不相同参数的两个祖先语言环境?