3
2
1

I'm having the following error when trying to follow the issue link that's described in this link.


Script error details: javax.script.ScriptException: com.exalate.api.exception.IssueTrackerException: Exalate can not create an issue with key `WAND-753` because there is already an issue with such key. Please review whether you'd like to delete that existing issue and resolve this error or .. Error line: CreateIssue.groovy:268


What I need to achieve is to get the issues linked in the project WAND, the other project (WNG) has the issue links, how could I do that when the issues already exist in project WAND? I mean, when they have already been synced... the docs describes a way to do the links when creating an Issue, is it possible to update the links when updating an issue?


  1. user-3fd1a

    Hi Jo,


    It is a bit unclear what you would like to achieve, can you go through it step by step?  


    • There  are 2 projects WAND / WNG
    • There is one connection  linking WAND with WNG
    • WNG has a number of issues that has links

    • ..


    Once that we understand, we  can provide an answer.

  2. Jonathan

    Sure, here are the steps/details:


    • There are 2 projects WNG and WAND
    • Both projects are connected 
    • WNG has epcis/stories with links like "blocked by", "blocks", etc
    • Issues got synced a day ago, but links were not made on project WAND (and the property `issueLinks` was in the scripts)
    • I tried to follow the guide that's in the docs: https://docs.idalko.com/exalate/display/ED/How+to+sync+issue+links+on+Jira+Cloud
    • I bulk exalated the filter configured for the project
    • The issues didn't sync and some errors were logged because the issues were already created on project WAND


    The code in the docs link explicitly says `IssueCreate.create`, in other words it will try to create an issue, the errors make sense, what doesn't make sense to me is that there's no well described guide to achieve this.


    Here are my scripts:


    Outgoing Sync
    // https://docs.idalko.com/exalate/display/ED/How+to+synchronize+epics
    Epic.sendEpicFirst()
    IssueLinkSync.send(replica, issue, httpClient)
    
    replica.key            = issue.key
    replica.type           = issue.type 
    replica.reporter       = issue.reporter
    replica.creator        = issue.creator
    replica.summary        = issue.summary
    replica.description    = issue.description
    replica.comments       = issue.comments
    replica.status         = issue.status
    replica.parentId       = issue.parentId
    replica.priority       = issue.priority
    replica.attachments    = issue.attachments
    replica.project        = issue.project
    replica.issueLinks     = issue.issueLinks
    replica.created        = issue.created
    replica.updated        = issue.updated
    
    // https://docs.idalko.com/exalate/display/ED/How+to+synchronize+versions
    replica.fixVersions    = issue.fixVersions
    
    // https://docs.idalko.com/exalate/display/ED/How+to+sync+story+points+field
    replica.customFields."Story Points" = issue.customFields."Story Points"
    
    if ((issue.type.name ?: issue.typeName) == "Epic") {
    	replica.customFields."Epic Name" = issue.customFields."Epic Name"
    }
    Incoming Sync
    if (firstSync) {
    
    	if(replica.project.key == "WAND") {
        	issue.projectKey   = "WNG"
            issue.typeName     = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Story"
        }
    	else if(replica.project.key == "WNG") {
        	issue.projectKey   = "WAND"
    		issue.typeName     = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Story"
        }
    }
    
    if (replica.project.key == "WAND") {
    	issue.labels  += nodeHelper.getLabel("Android")
    }
    
    issue.summary      = replica.summary
    issue.description  = replica.description
    issue.issueLinks   = replica.issueLinks
    issue.priority     = replica.priority
    
    issue.comments     = commentHelper.mergeComments(issue, replica)
    issue.attachments  = attachmentHelper.mergeAttachments(issue, replica)
    issue.priority     = nodeHelper.getPriority(replica.priority?.name ?: "Medium")
    
    issue.customFields."Story Points"?.value = replica.customFields."Story Points".value
    
    // https://docs.idalko.com/exalate/display/ED/How+to+synchronize+versions
    // assign fix versions from JIRA A to JIRA B
    // issue.fixVersions  = replica
    //	.fixVersions
    	// ensure that all the fixVersions are available on B
    //	.collect { v -> nodeHelper.createVersion(issue, v.name, v.description) }
    
    if (issue.typeName == "Epic") {
        issue.customFields."Epic Name"?.value = replica.customFields."Epic Name"?.value ?: replica.summary
    }
    
    Epic.receive()
    
    if(firstSync) {
      // https://docs.idalko.com/exalate/display/ED/How+to+sync+issue+links+on+Jira+Cloud
      return CreateIssue.create(
           replica,
           issue,
           connection,
           issueBeforeScript,
           traces,
           blobMetadataList,
           httpClient,
           syncRequest
          ) {
        IssueLinkSync.receive(replica, issue, httpClient, nodeHelper)
      }
    }


    I've placed the `CreateIssue.create...` code from the docs inside the firstSync validation to avoid errors, but I can't get my issues linked in WAND project, the steps you mentioned at the Atlassian post doesn't work either.

CommentAdd your comment...

1 answer

  1.  
    2
    1
    0

    Sorry for the delay here.   


    The problem is that Epic.receive has an embedded issue creation logic resulting in a conflict with the createIssue used after it.


    (I know - we need to do a better job in the documentation)


    Now the solution is to add a parameter in the createIssue


    The method signature is

    BasicIssueKey create(
                boolean reuseIssue,
                BasicHubIssue replica,
                BasicHubIssue issue,
                com.exalate.api.domain.connection.IConnection relation,
                com.exalate.node.hubobject.v1_3.NodeHelper nodeHelper,
                BasicHubIssue issueBeforeScript,
                com.exalate.api.domain.INonPersistentReplica remoteReplica,
                List<com.exalate.api.domain.twintrace.INonPersistentTrace> traces,
                List<com.exalate.api.domain.IBlobMetadata> blobMetadataList,
                Closure<?> whenIssueCreatedFn)



    The default value for reuseIssue is 'false'. When you change the call to  (check line 2) - you should be fine


      return CreateIssue.create(
           true,
           replica,
           issue,
           connection,
           issueBeforeScript,
           traces,
           blobMetadataList,
           httpClient,
           syncRequest
          ) {
        IssueLinkSync.receive(replica, issue, httpClient, nodeHelper)
      }


    Can you  check and let us know

      CommentAdd your comment...