How to synchronize two Jira instances without being ruined!
In this article, you will learn how to have two Jira instances synchronizing issues between each other using the "Integrations Hub for Jira" app.
The iHub can be downloaded here: https://marketplace.atlassian.com/1220905
Why running multiple instances?
The reasons for running multiple instances varies depending on the use case.
For example:
- Your company has separated customer support and development Jiras
- You have an outsourced department using a separate Jira
- You've merged with another company ending up in multiple Jira instances
The problem
Jira does not support synchronizing multiple instances out of the box, you will need a third-party app to do do this. This article will show you how to do this with the iHub app. Get the app here: https://marketplace.atlassian.com/1220905
Synchronizing new issues from Jira A to Jira B
Start by installing iHub from the Atlassian Marketplace.
This is what we want to accomplish:
- All Jira issues, in a project, that are created in "Jira A" shall be synchronized to "Jira B" and vice versa.
- Synced issues shall be back referenced in "Jira A" for future tracking. (see syncing everything below)
Setup in Jira A: Authentications
First, create authentication for Jira B access. Go to "Manage Apps -> Integrations Hub and click the lock icon.
The iHub has support for
- Oauth2 (with support for authorization code, implicit, resource owner password, client credentials, and authorization code with assertion)
- Basic auth
- Bearer tokens
Here, we're creating a basic auth for accessing the Jira B instance. Authentications are reusable and can be used for multiple integration actions.
Integration configuration
Next, set up the configurations for syncing Jira A to Jira B.
Setting up integrations is easy, it's a no-code, user-friendly interface.
The iHub talks REST. We're using Jiras REST API to synchronize new issues to Jira B-instance.
- Select HTTP method POST and enter the Jira B instance URL followed by /rest/api/2/create which is the Jira API endpoint for creating issues. (For convenience, iHub has templates that fill this in for you)
- Select the authentication created in the previous step, here it's JIRA B User[BASIC_AUTH]
Note: Make sure that the HTTP Headers have Content-Type set to application/json, if not, just add it manually.
3. Fill in the fields that you want to set in the Jira B synched issue. Read more about the Jira API here: https://docs.atlassian.com/software/jira/docs/api/REST/8.8.1/
Note how we access variables by using for the Mustache expression {{ issue }} This will get you access to the issue within this scope. (scope = issue that triggered this integration to run)
Access issue properties like this {{issue.summary}} to get the summary. {{issue.issueType.name}} to get the issue type name. All this is documented here: https://doc.rixter.se/display/RIFJ/
Trigger configuration
For the synchronization to happen we need to set up a trigger. In this case, we will listen to all issue created events.
- Select "Issue Created" in the event triggers list. This will trigger this integration every time a new issue is created.
- Add a JQL condition to narrow the scope on which issues that are synced, or leave blank to sync everything. In this example were only synchronizing the project "SYNCIT"
That's it! Now all new issues in Jira A that are created in project SYNCIT will be posted to Jira B.
Saving issue key from Jira B
Since we most likely want to synchronize issue updates, comments, i.e. we need to store the issue key from the newly created issue in Jira B.
This is the response from the Jira B create issue API
Now, let's use this and update the triggering issue with the key from this response. This is done by creating a "child action".
A "child action" can use the response from its parent and do what it needs with it. It gets triggered after the parent has been triggered.
Creating a child action
Create a new action, let's call SYNC - Set Reference
1. Select the "Auto-generate 1st level as variables from response". This will make the first level of json response available as variables.
In this example: id, key, self will be accessible by using Mustache templates ie. {{ key }}.
( If you need variables further down the json response you can specify a json path manually to get hold of that variable. )
2. Fill in the URL details, in this example, we're updating our parent issue using the Jira REST API.
HTTP method PUT, the URL is {{baseUrl}} /rest/api/2/issue/{{issue.key}}
3. Select an authentication that has access to Jira A (If no one exists, create one following the steps above)
5. Fill in the PUT body. Here we're using the {{ key }} variable auto-generated from 1 above.
That's it!
Now you're all set for synchronizing two Jira instances.
If you need advice on how to sync comments, updates, and transitions please feel free to reach out to us.
Get the app here: https://marketplace.atlassian.com/1220905
Read more:
- https://www.dhirubhai.net/pulse/how-integrate-jira-servicenow-5-minutes-rickard-atthem
- https://www.dhirubhai.net/pulse/more-productive-inbox-jira-in-app-notifications-rickard-atthem
- https://www.dhirubhai.net/pulse/jira-integrations-automation-made-simple-rickard-atthem
- https://www.dhirubhai.net/pulse/how-speed-up-your-jira-service-desk-approval-workflow-rickard-atthem