Start Synchronisation of a linked issue

Originally asked by Thomas Karrer on 23 July 2020 (original question)


Hello

I’ve the following problem:

In project A a transition in testcase A1 a bug A2 automatically is created as a linked issue to testcase A1.
After this postfunction we need a new postfunction in A1 to exalate A2 with project B

Thanks in advance

Thomas


Answer by André Leroy-Beaulieu Castro on 23 July 2020

Hi Thomas,

Here is a snippet you could use in your Outgoing script to automatically sync the bugs that are linked to a testcase, just make sure the names of the issue types is the same as in your Jira:

//Outgoing:

def exaCl = com.atlassian.jira.component.ComponentAccessor
    .pluginAccessor
    .getEnabledPlugin("com.exalate.jiranode")
    .getClassLoader()
def exaSyncServiceClass = exaCl.loadClass(
"com.exalate.api.trigger.ISyncInitiationService"
) 
def syncService = com.atlassian.jira.component.ComponentAccessor.getOSGiComponentInstanceOfType(
    exaSyncServiceClass
)
 def im = com.atlassian.jira.component.getIssueManager()

if (issue.typeName == "Testcase") {
    replica.issueLinks.collect{ link ->
     def linkedIssue = im.getIssueObject(link.otherIssueId)
     if (linkedIssue.issueType.name == "Bug") {
        syncService.pair(
          linkedIssue.key, // specify the issue key you want
          connection.name // set the relevant connection name
        )
     }
  }
}

Thanks,

André


Answer by Francis Martens (Exalate) on 23 July 2020

Can you use the ‘Exalate Now’ Postfunction and add it to the create transition of the bug?
If that is not an option, you could also set a custom field on the bug, and exalate it using a trigger.
Additionally you can test in the outgoing sync if an issue is linked to a testcase which is under sync by traversing the issue.links

There are quite a bit of different options.


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.