如何复制詹金斯秘密文件 [英] How to copy Jenkins secret files

查看:14
本文介绍了如何复制詹金斯秘密文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将 2 个秘密文件添加到 Jenkins 凭证中,名称分别为 PRIVATE-KEYPUBLIC-KEY.如何将这 2 个文件复制到作业中的 /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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆