Cloned JIRA Instance Synchronization


Basic behavior

Here is a description how normal synchronization process executes:

  1. You have issue in JIRA A instance, you click on create remote ( it can be made automatically when you set up the triggers in contract configuration e.g onCreatedIssue or onUpdatedIssue)
  2. The request is send to JIRA B instance to create issue ( corresponding to the contract, which caused the request )
  3. Issue is created, response to JIRA A is sent. 
  4. Your issues are now synchronized.

Clone JIRA instance

Let's assume you already have issues on both JIRA instances, which you want to synchronize between instances but you don't want to trigger create new remote issues. In other words you want to synchronize issues that already exists.

FYI if the issues are totally different they might and they will (when the synchronization will take place, e.g on issue update) override their field values!!!*
*only those which are defined in contract AND only those which has been changed after this synchronization set up

You will need:

  1. Basic / Intermediate knowledge of SQL
  2. Access to the database will privileges to insert data

DB mapping explanation:

Information about which issue from JIRA A is synchronized to one from JIRA B is stored in sync_issue table (ao_6d516b_sync_issue).
This table has 5 columns CONTRACT_ID, ID, ISSUE_ID, REMOTE_ISSUE_ID, REMOTE_ISSUE_KEY.
As you might expect:

    • contract_id - relates to contract you have already set up e.g: 1
    • id - is just an id of the current entity ( mapping information ) e.g: 1
    • issue_id - relates to internal issue id (JIRA A) e.g: 10100
    • remote_issue_id - relates to external issue id (JIRA B) e.g: 10101
    • remote_issue_key - relates to external issue key (JIRA B) e.g: PRO-12

What you need to do is: just add new entity to the database, which will correspond to your desired mapping. 

Step-by-step guide

Glossary: 

  • <JIRA-A-DB> - is the pointer to the JIRA A database scheme
  • {} - provide a value here 

Explenation: 

  • You may omit id column, because it isn't referencing to any external source at the moment
  • You need to run this SQL queries both on JIRA A and JIRA B (values may be different or identical if your instances are cloned)
  • Queries has been made for mySQL

CASE 1: 
You want to map only selected issues, just do it manually by providing ids:

SQL Query
INSERT INTO <JIRA-A-DB>.ao_6d516b_sync_issue 
	( CONTRACT_ID, ISSUE_ID, REMOTE_ISSUE_ID, REMOTE_ISSUE_KEY ) 
VALUES 
	( {(JIRA-A) contract_id-1}, {(JIRA-A) issue_id-1}, {(JIRA-B) issue_id-1}, {(JIRA-B) issue_key-1} ),
	( {(JIRA-A) contract_id-2}, {(JIRA-A) issue_id-2}, {(JIRA-B) issue_id-2}, {(JIRA-B) issue_key-2} ),
	( {(JIRA-A) contract_id-3}, {(JIRA-A) issue_id-3}, {(JIRA-B) issue_id-3}, {(JIRA-B) issue_key-3} )


CASE 2:

You have dumped your database and imported it as is. In this case you must copy the attachments from JIRA A installation directory to JIRA B installation directory (if you have them and want to use them) after you start the JIRA first thing to do is reindex. 

Because those databases are identical, the query can be simplified and run on both instances. 

SQL Query
INSERT INTO <JIRA-A-DB>.ao_6d516b_sync_issue ( CONTRACT_ID, ISSUE_ID, REMOTE_ISSUE_ID, REMOTE_ISSUE_KEY )
    SELECT 
        contract.CONTRACT_ID AS CONTRACT_ID,
        issue.ID AS ISSUE_ID, 
        issue.ID AS REMOTE_ISSUE_ID,
        concat(contract.PROJECT_KEY, "-", issue.issuenum) AS PROJECT_KEY
    FROM (
        SELECT
            c.ID AS CONTRACT_ID,
            proj.PROJECT_ID AS PROJECT_ID,
            proj.PROJECT_KEY AS PROJECT_KEY
         FROM <JIRA-A-DB>.ao_6d516b_contract c 
         JOIN <JIRA-A-DB>.project_key proj ON c.PROJECT_ID = proj.PROJECT_ID
    ) AS contract
	JOIN <JIRA-A-DB>.jiraissue issue ON contract.PROJECT_ID = issue.PROJECT


Treat this as a tutorial. If you want to perform this operations please verify if they are working on you database.

If you are trying to perform a more complex mapping and you struggle with that, contact with us!