How to merge two GitHub Organization Projects

Article ID:360025186551
2 minute readKnowledge base

Issue

  • I would like to merge two GitHub Organizations on GitHub and do the same on my Jenkins controller while retaining build history

Environment

  • Any Jenkins controller with GitHub Branch Source Plugin

Resolution

Always make sure to take a backup of Jenkins before performing a migration like this.
  1. Turn off the Organization Scanning on the GitHub Organization job or shutdown Jenkins. Having an Organization scan run while you are in the middle of migrating the repos may lead to undesirable results.

  2. Copy the repository directories from source GitHub Organization job to the destination GitHub Organization job. These will be located in $JENKINS_HOME/jobs/<GITHUB_ORG_JOB>/jobs. NOTE: The <GITHUB_ORG_JOB> directory will have the name originally set when the GitHub Organization item was created. This may be different than what is displayed in the Jenkins UI. To find the correct name, navigate the GitHub Organization in the Jenkins UI. Then look at the end of the web browser URL to find the correct directory name.

  3. Migrate repositories from the old Organization to the new one on the GitHub server. Make sure the names of the repositories and branches do not change or it will create new directories in the job on Jenkins.

  4. Restart Jenkins. The copied repositories will now show up in the UI for the destination GitHub Organization job. They will still have their old configuration at this point.

  5. Run an Organization Scan on the destination job. This will find all the new repositories and should recognize that the source has changed in the copied directories and update the configurations to match this new job. NOTE: This will kick off a "build storm" as all the copied repositories branches will now begin to build simultaneously. You will see something like this in the Scan Repository Log for each copied repository:

Takeover for github_test2 » java-project » development by source #1 from source that no longer exists
Branch reopened: development (63ddf3477f0d72c99e687d5859666315bc0650f9)
Scheduled build for branch: development

6.Lastly, you will want to check the configurations within the job of the repositories and branches that were copied over to verify they were updated correctly. Also make sure that the build history is still intact and that builds are completing successfully from the new GitHub Organization.