We had a client reach out to us, asking how they could add repositories to Jira via the API. Unfortunately, there is no official API for this, and thus, no method that Atlassian supports for doing this. We dug into the private APIs and dug up how to do this. The APIs are the same for Bitbucket, GitHub, and GitHub Enterprise. These API calls are based on the idea that you have already established a connection between Jira and your DVCS server of choice, and are now looking specifically to add repositories to sync. We’re sharing this with everyone so that you can benefit from this as well:
Please do keep in mind that this is not a supported method of doing this. If you contact Atlassian about this, they will not support you. If you need help solving advanced Atlassian challenges like this one, please reach out!