How to migrate credentials to a new Jenkins instance


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


  • CouldBees CloudBees Jenkins Enterprise (CJE)
  • CloudBees Operations Center (CJOC)
  • Jenkins
  • Credentials Plugin


1. Stop new and old Jenkins instances.

2. (optional) Delete file identity.key.enc from $NEW_JENKINS_HOME/identity.key.enc. In case you don’t delete it manually, it will be done automatically after the next restart

SEVERE: identity.key.enc is corrupted. Identity.key.enc will be deleted and a new one will be generated
javax.crypto.BadPaddingException: Given final block not properly padded

For migrating Global scope credentials:

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

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

On linux:

rm JENKINS_HOME/identity.key.enc 

For migrating Folder and User scope credentials:

5. Copy credentials.xml files from $OLD_JENKINS_HOME/jobs/FOLDER_NAME/credentials.xml to $NEW_JENKINS_HOME/jobs/FOLDER_NAME/. This should be done in each folder you would like to migrate and should be adapted to your specific folder paths/structure.

6. Copy credentials.xml files from $OLD_JENKINS_HOME/users/USER_NAME/credentials.xml to $NEW_JENKINS_HOME/users/USER_NAME/. This should be done in each of the users you would like to migrate.

7. Finally, restart the instances and the identity.key.enc should be regenerated on the new instance.

Have more questions? Submit a request


  • 0
    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.

Please sign in to leave a comment.