git - 在声明性 Jenkins 管道中从私有 Git 存储库下载单个文件
问题描述
我已经看过这个问题,但我想知道如何在声明性管道中安全地从私有 Git 存储库下载一个,最好使用凭证 ID 或类似的。
我想我必须使用类似的东西:
sh 'git archive ... || tar --extract'
解决方案
为此,可以在管道脚本中使用 ssh 代理插件:
sshagent(credentials: ['credentials-id']) {
sh "git archive --remote=${git_repository_url} --format=tar ${branch_name} ${path_to_the_file/filename or only the filename} | tar xf -"
}
推荐阅读
- spring-boot - SpringBoot中的rails是否有等效于before_filter的方法?
- php - $_SERVER['DOCUMENT_ROOT'] 的目的是什么
- java - 我想将 String 数组转换为 int 数组以显示总数
- c# - 有没有办法在扩展/动态上使用 FastMember ObjectReader
- apache-spark - PySpark 脚本缓慢,体积非常小
- spss - 用 5 个数据点计算 DDT 任务的 AUC
- c# - 如何让精灵每 10 秒过渡到一个新的精灵
- aurelia - 在路由器中添加条件以在 Aurelia 中进行相应导航
- mysql - 错误:使用 IN 时,子查询返回多于 1 行
- amazon-web-services - 如何使用 boto3 获取分配给 cloudformation 堆栈的标签?