Migrating Jenkins Credentials

July 5, 2019

If you need to migrate a Jenkins Instance to newer instance, there may be need to import credentials. If that is the case then the following may help:

  1. First stop both Jenkins instances.

  2. Within the New Jenkins Instance remove the identity.key.enc file which can be found in $JENKINSHOME

$ rm identity.key.enc

  1. Zip up the credentials.xml file and anything beginning with secret in the $JENKINSHOME directory. Afterwards we will send it to the new Jenkins instance.
$ tar -czvf credentials.tgz secret* credentials.xml
$ scp credentials.tgz [email protected]:/tmp/

  1. Next extract the credentials.tgz file in the $JENKINSHOME directory and start up your new Jenkins instance.
$ tar -xzvf /tmp/credentials.tgz $JENKINSHOME

After you start up your new Jenkins instance you should be set. Note that in the event you do not see the exported credentials, you should restart you new Jenkins instance.

_Special thanks to https://itsecureadmin.com/2018/03/jenkins-migrating-credentials/_