如何复制詹金斯机密文件 [英] How to copy Jenkins secret files
本文介绍了如何复制詹金斯机密文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在Jenkins凭证中添加了两个秘密文件,名称分别为PRIVATE-KEY
和PUBLIC-KEY
.
如何将这两个文件复制到作业内的/src/resources
目录中?
I have already added 2 secret files to Jenkins credentials with names PRIVATE-KEY
and PUBLIC-KEY
.
How can I copy those 2 files to /src/resources
directory inside a job?
我有以下代码段
withCredentials([file(credentialsId: 'PRIVATE_KEY', variable: 'my-private-key'),
file(credentialsId: 'PUBLIC_KEY', variable: 'my-public-key')]) {
//how to copy, where are those files to copy from?
}
推荐答案
好的,我想我做到了. my-private-key
变量是秘密的路径,因此我不得不将该秘密复制到所需的目的地.
Ok, I think I managed to do it. my-private-key
variable is a path to the secret, so I had to copy that secret to the destination I needed.
withCredentials([file(credentialsId: 'PRIVATE_KEY', variable: 'my-private-key'),
file(credentialsId: 'PUBLIC_KEY', variable: 'my-public-key')]) {
sh "cp \$my-public-key /src/main/resources/my-public-key.der"
sh "cp \$my-private-key /src/main/resources/my-private-key.der"
}
这篇关于如何复制詹金斯机密文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文