How to transfer Jenkins Credentials to an new server

I am moving projects and credentials from a Jenkins controller:
Jenkins: 2.320
OS: Linux - 3.10.0-1160.105.1.el7.x86_64
Java: 1.8.0_402 - Red Hat, Inc. (OpenJDK 64-Bit Server VM)

to a new Jenkins controller:
Jenkins: 2.440.1
OS: Linux - 5.14.0-362.18.1.el9_3.x86_64
Java: 17.0.10 - Red Hat, Inc. (OpenJDK 64-Bit Server VM)

I would like to know how to migrate the all the store credentials to new server. The list of credentials with their Store, Domain, ID and names can be seen under Manage Jenkins → Credentials.
The new server is a clear Jenkins fresh install. Has its own encryption keys.
I tried to this:

  1. Stop Jenkins on new server.
    new-server # /etc/init.d/jenkins stop
  2. Remove the identity.key.enc file on new server:
    new-server # rm identity.key.enc
  3. Copy secret* and credentials.xml to new server.
  4. Start Jenkins.
    new-server # /etc/init.d/jenkins start
    solution from Jenkins: Migrating credentials… –
    with no success. I still don’t see the credentials from the source server.
    Thanks for you help if you can give me a solution that works moving credentials from a 2.32 jenkins server to Jenkins: 2.44 server.
    I understand that the credentials are encrypted with a key or a combination of keys specific to the server. I am not looking for a hack but a migration path.
    Thanks a lot for your help.
1 Like