如何将凭证从一个 jenkins 实例导出到另一个实例? [英] How to export credentials from one jenkins instance to another?
问题描述
我在 Jenkins 中使用凭据插件来管理我团队构建的 git 和数据库访问凭据.我想将凭证从一个 jenkins 实例复制到另一个独立的 jenkins 实例.我该怎么做?
I am using the credentials plugin in Jenkins to manage credentials for git and database access for my team's builds. I would like to copy the credentials from one jenkins instance to another, independent jenkins instance. How would I go about doing this?
推荐答案
UPDATE: TL;DR 按照 链接 在下面由 Filip Stachowiak 的评论中提供,这是最简单的方法.如果它不适合你继续阅读.
UPDATE: TL;DR Follow the link provided below in a comment by Filip Stachowiak it is the easiest way to do it. In case it doesn't work for you go on reading.
复制 $HUDSON_HOME/credentials.xml 不是解决方案,因为 Jenkins 对密码进行加密,除非两者共享一个公共密钥,否则其他实例无法解密这些密码.
Copying the $HUDSON_HOME/credentials.xml is not the solution because Jenkins encrypts paswords and these can't be decrypted by another instance unless both share a common key.
因此,要么在两个 Jenkins 实例中使用相同的加密密钥(Jenkins 中存储的加密密钥在哪里?)或者您可以做的是:
So, either you use the same encription keys in both Jenkins instances (Where's the encryption key stored in Jenkins? ) or what you can do is:
- 创建相同的用户/密码,您需要在第二个 Jenkins 实例中共享,以便生成有效密码
真正重要的是两个credentials.xml 中的用户ID 是相同的.为此(请参阅下面的credentials.xml 示例)对于用户:Jenkins 标识符
必须是在两个credentials.xml中相同c4855f57-5107-4b69-97fd-298e56a9977d
- Create the same user/password, you need to share, in the 2nd Jenkins instance so that a valid password is generated
What is really important is that user ids in both credentials.xml are the same. For that (see the credentials.xml example below) for user: Jenkins the identifier
<id>c4855f57-5107-4b69-97fd-298e56a9977d</id>
must be the same in both credentials.xml
<com.cloudbees.plugins.credentials.SystemCredentialsProvider plugin="credentials@1.22">
<domainCredentialsMap class="hudson.util.CopyOnWriteMap$Hash">
<entry>
<com.cloudbees.plugins.credentials.domains.Domain>
<specifications/>
</com.cloudbees.plugins.credentials.domains.Domain>
<java.util.concurrent.CopyOnWriteArrayList>
<com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
<scope>GLOBAL</scope>
<id>c4855f57-5107-4b69-97fd-298e56a9977d</id>
<description>Para SVN</description>
<username>jenkins</username>
<password>J1ztA2vSXHbm60k5PjLl5jg70ZooSFKF+kRAo08UVts=
</password>
</com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
</java.util.concurrent.CopyOnWriteArrayList>
</entry>
</domainCredentialsMap>
</com.cloudbees.plugins.credentials.SystemCredentialsProvider>
这篇关于如何将凭证从一个 jenkins 实例导出到另一个实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!