I already had a look at this question , but I wonder how I can securely download a single from a private Git repository in a declarative pipeline, preferably using a credentials ID or similar.
I assume I have to use something like:
sh 'git archive ... || tar --extract'
for this purpose there is a ssh agent plugin that can be used within the pipeline script:
sshagent(credentials: ['credentials-id']) {
sh "git archive --remote=${git_repository_url} --format=tar ${branch_name} ${path_to_file} | tar xf -"
}
Note: path_to_file
can be either the path to a file, or just the filename
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.