我已经查看了this question,但我想知道如何从声明性管道中的私有Git存储库中安全地下载单个,最好使用凭据ID或类似的。
我认为我必须使用类似的东西:
sh 'git archive ... || tar --extract'
答案 0 :(得分:1)
为此目的,有一个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 -"
}