user1421936
user1421936

Reputation: 41

JIRA 4.2.1 & JIRA 4.3.3 integration through email

I want to integrate 2 JIRA instances through email, one uses Jira 4.2.1 and the other uses 4.3.3.

one instance has certain custom fields, another has certain custom fields, both of the JIRA instances has to interchange the issue details, updates of the issue, through email. i.e both has to be in sync.

For Example

1) if an issue is created in Instance 1, a mail will be triggered and using that email, Instance 2 will create an issue there.

2) Also, if there is a update for an issue in Insance1 then a mail will be triggered to Instance 2 which will update the same issue in Instance 2.

Hope it clears !!

Upvotes: 2

Views: 409

Answers (1)

Kuf
Kuf

Reputation: 17846

If I got your intentions right, i believe that there is an easier way to do so using the Jira remote API. For example, you could easily write a Python script, using the XML-RPC library, comparing the two systems and updating them if needed.

The problem with the email method you suggested is that you could easily create an endless loop of issue creating...

First, create a custom field in both instances, and call it something like "Sync". This will be used to mark issues once we'll sync them.

Next, enable the RPC plugin.

Finally, write a script that will copy the issues via RPC, example:

#!/usr/bin/python

# Sample Python client accessing JIRA via XML-RPC. Methods requiring
# more than basic user-level access are commented out.
#
# Refer to the XML-RPC Javadoc to see what calls are available:
# http://docs.atlassian.com/software/jira/docs/api/rpc-jira-plugin/latest/com/atlassian/jira/rpc/xmlrpc/XmlRpcService.html

import xmlrpclib

s1 = xmlrpclib.ServerProxy('http://your.first.jira.url/rpc/xmlrpc')
auth1 = s1.jira1.login('user', 'password')

s2 = xmlrpclib.ServerProxy('http://your.second.jira.url/rpc/xmlrpc')
auth2 = s2.jira1.login('user', 'password')

# go trough all issues that appear in the next filter
filter = "10200"
issues = s1.jira1.getIssuesFromFilter(auth1, filter)

for issue in issues:
# read issues: 
for customFields in issue['customFieldValues']:
    if customFields['customfieldId'] == 'customfield_10412': # sync custome field
        # cf exists , dont sync!
        continue
    # no sync field, sync now
    proj = issue['project']
    type = issue['type']
    sum = issue['summary']
    desc = issue['project']
    newissue = s2.jira1.createIssue(auth2, { "project": issue['project'], "type": issue['type'], "summary": issue['summary'], "description": issue['description']})
    print "Created %s/browse/%s" % (s.jira1.getServerInfo(auth)['baseUrl'], newissue['key'])
    # mark issue as synced 
    s.jira1.updateIssue(auth, issue['key'], {"customfield_10412": ["yes"]})

The script wasn't tested but should work. You'll probably need to copy the rest of the fields you have, check out this link for more info. As well, this is just one way sync, you have to sync it the other way around as well.

Upvotes: 0

Related Questions