How to migrate credentials to a new Jenkins instance?

Issue

  • I have a new instance of Jenkins and want to migrate credentials from an old instance.

Environment

Resolution

Case A - Root Level

1. Stop new and old Jenkins instances.

2. Delete file identity.key.enc from $NEW_JENKINS_HOME/identity.key.enc.

rm JENKINS_HOME/identity.key.enc 

3. Copy secret files and folder from $OLD_JENKINS_HOME/secret* to the new $NEW_JENKINS_HOME root

cp -R $OLD_JENKINS_HOME/secret* $NEW_JENKINS_HOME

4. Copy credentials.xml file from $OLD_JENKINS_HOME/credentials.xml to the $NEW_JENKINS_HOME root

cp $OLD_JENKINS_HOME/credentials.xml $NEW_JENKINS_HOME

5. Finally, restart the new instance. Note that identity.key.enc should be regenerated on the new instance.

Case B - User and Folder Level

Credentials at User and Folder level are embedded in their respective config.xml so the recommended way to do it is by Migrating Entire Jenkins Configuration, Including Jobs.

Have more questions? Submit a request

3 Comments

  • 0
    Avatar
    Aurelio Soria

    This worked for me without deleting secret and the identity files. But, my old jenkins is v. 1.599 to latest CJE. I just stop jenkins secure copy over credentials.xml and start jenkins. All good.

  • 0
    Avatar
    Phanikumar Dadi

    I would like to migrate my old Jenkins server 1.565.3 to a new Jenkins latest version on another instance. So,  I have copied all the files listed above. But I am still getting an issue with Git credentials. Can someone help me out on this.

  • 0
    Avatar
    James Brown

    Hi Phanikumar,

    I wasn't able to identify if you're an existing customer. If you are we'd be happy to assist over a case. Otherwise, you might ask in our subscriber Community.

    If you'd like me to connect you with an Account Executive to discuss a subscription you can email me directly jbrown@cloudbees.com

Please sign in to leave a comment.