Copying Jenkins home gives duplicate instance ids

Issue

  • I want to create a clone from an existing $JENKINS_HOME for another Jenkins instance id
  • I create/regenerate a new instance id
  • I am migrating my instance to a new environment

Environment

Resolution

If you need to duplicate a Jenkins instance by copying the entire $JENKINS_HOME it will lead to duplicate instance ids. You can re-create the instance id for the new Jenkins installation by doing the following:

  1. Stop the Jenkins instance.
  2. cd to $JENKINS_HOME
  3. Delete the current secret.key file: rm secret.key
  4. Delete the license.xml file: rm license.xml
  5. Start Jenkins again.

To get the license ID follows this article What is a CloudBees Instance ID and how do I find it?.

Have more questions?

9 Comments

  • 1
    Avatar
    Alexander Ost

    It seems that some additional steps are required when copying a JENKINS_HOME of a 2.7.19.1 CJEE master that's connected to CJOC. I had to force-push a new clienst master connection from cjoc side to get the copy running properly.

    Edited by Alexander Ost
  • 0
    Avatar
    Brian Vandegriend

    I tried these steps with Jenkins 2.7.19 and it doesn't work (I'm not using Operation center). 

    I deleted the secrets.key file along with license.xml. When I restarted the Jenkins service on the test server, I got this fatal error: "An error occurred: Default update site connectivity check failed with fatal error: Cannot check connection status of the update site with ID='cje-offline'." 

     

  • 0
    Avatar
    Lokesh Kamalay

    maybe this information related to CJP is outdated now as CJE and Jenkins X are dominating,

    I had to follow these steps to make it work.

    1. Login to Jenkins Master and Remove all these files

    • $JENKINS_HOME/license.xml
    • $JENKINS_HOME/operations-center-cloud*
    • $JENKINS_HOME/operations-center-client*
    • $JENKINS_HOME/com.cloudbees.opscenter.client.plugin.OperationsCenterRootAction.xml

    2. Disable the Security,

    Open $JENKINS_HOME/config.xml. Locate this line: <useSecurity>true</useSecurity> and changing it to <useSecurity>false</useSecurity>


    3. Start the Jenkins Service


    4. Create a new client master in CJOC and push the configuration which will now allow you to connect successfully.

  • 0
    Avatar
    Harish Jangam

    I tried the above steps for Operations Centre and got the error :

    Default update site connectivity check failed with fatal error: Cannot check connection status of the update site with ID='cjoc-offline'. This update center cannot be resolved. If you see this issue for the custom Jenkins WAR bundle, consider setting the correct value of the hudson.model.UpdateCenter.defaultUpdateSiteId system property (requires Jenkins restart). Otherwise please create a bug in Jenkins JIRA.

  • 1
    Avatar
    Lokesh Kamalay

    It looks like the custom update center site is not reachable from the environment.  Change it to default and try, or configure the proxy if you are behind the corporate firewall.

  • 0
    Avatar
    Harish Jangam

    @lokesh Kamalay,

    I tried spinning up the new Jenkins on the same instance and I was able to download all the default plugins. But when I copied the production Jenkins_home to new instance and removed the secret.key and license.xml I'm seeing the above error. 

    However, is there any way to get the Jenkins up and running without connecting to update center ??

  • 1
    Avatar
    Lokesh Kamalay

    I would do this,

    1. Before restore, take a backup of $JENKINS-OC_HOME/hudson.model.UpdateCenter.xml
    2. Restore the Jenkins

    3. Restore the above backed up file and start the Jenkins

     

    If above is not possible, then just edit the $JENKINS-OC_HOME/hudson.model.UpdateCenter.xml file and remove the entries of cjoc-offline (needs to delete the complete section)

  • 0
    Avatar
    Harish Jangam

    I have the same file content in old and new jenkins_home folder:

    <?xml version='1.1' encoding='UTF-8'?>
    <sites>
    <jenkins-enterprise plugin="nectar-license@8.26">
    <id>jenkins-operations-center</id>
    <url>https://jenkins-updates.cloudbees.com/update-center/operations-center/update-center.json</url>
    </jenkins-enterprise>

  • 0
    Avatar
    Lokesh Kamalay

    Hmm.. don't know mate then.  @cloudBees may provide more info on that then.

Please sign in to leave a comment.