2
1
0

Hi,


I have an issue I need some help solving. We are using Exalate to synchronize issues between one Jira instance. But we would like to stop the sync when the remote issue is closed, but still keep the connection. In Idalkos documentation I have only found Unexalate for this purpose, which can be done through a post function, but that will remove the connection between the issues, which we don’t want, so therefore I’m looking for another solution for this. Perhaps it’s possible to add some code in the incoming sync that will first look at the status of the issue, if the issue is closed then stop the sync. Is this possible?


Many thanks in advance!

Kind regards,
Simone

    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      Hi Serhiy Onyshchenko, thanks for you answer! But unfortunately the remote issue isn't closed (in reality it can still be open for a while). Couldn't this be done through the incoming sync?

      1. Simone Svedin

        And to add, I have found this post


        if (!firstSync && replica.status.name == "Closed") {
            //here you add the script rules you want to run when the remote side is closed, and it's not first sync.
        }

        But I what should I write between the brackets? and where should I add it? and another question, the workflow that we ar using have three Close statuses (Closed, Declined and Invalid). How should I write to make it possible to state all three? or perhaps change the code to Status Category, i.e Done?

      2. Ariel Aguilar

        You can do something like:

        if(replica.status.name == "Closed" || replica.status.name == "Declined" || replica.status.name == "Invalid"){return
        }

        It should be added on the side you want to stop sync rules from been sent. (Outgoing sync)
        Kind regards,

        Ariel

      3. Simone Svedin

        Hi Ariel Aguilar, thanks for your reply. But I can't add it to the outgoing sync. It needs to be in the incoming, because the remote issue where the sync is been sent from is still open. It's the other issue that is closed. Couldn't this be done in the incoming sync?

      4. Ariel Aguilar

        Then, is it possible to add the following snippet on the Outgoing sync, on the remote side where the issue it is closed, so you can try:

        if(issue.status.name == "Closed" || issue.status.name == "Declined" || issue.status.name == "Invalid"){
        return
        }

        Kind regards,

        Ariel

      5. Simone Svedin

        Hi Ariel Aguilar , not sure I'm following. The scenario: Issue 1 = status Open, Issue 2 = status Closed. Issue 1 gets updated and will trigger a sync to remote issue 2. Issue 2 retrieves the incoming sync and the issue will get updated, this is what I want to avoid. Adding a snippet to the outgoing sync for issue 1 or 2 won't help. IF both the issues where closed, then yes, but on the other hand the issue should't be updated when its closed either so the problem exist while one issue is still open and still trigger sync to the remote issue. So I can't see how to solve this any other way than adding a snippet to the incoming sync?

      6. Ariel Aguilar

        Hi Simone,

        From your scenario, then you can do the following. Let's call Issue 1 A side and Issue 2 B side. If the issue 2 gets updated to Closed status. You will want/need to prevent the update to push from B side to A side. So, you will add on B side Outgoing sync: 

        if(issue.status.name == "Closed" || issue.status.name == "Declined" || issue.status.name == "Invalid"){
        return
        }

        Then, if you do an update from A side on Issue 1 and you don't want this to be updated on B side. You can also implement the same code on B side incoming script:

        if(issue.status.name == "Closed" || issue.status.name == "Declined" || issue.status.name == "Invalid"){
        return
        }

        In this case, your incoming rules from B side won't be executed if you match the criteria as we discuss in this scenario.

        Kind regards,

        Ariel

      7. Simone Svedin

        Hi Ariel Aguilar, I added the code on the B side incoming script, right on the top. Which worked just as I wanted! But now I get an error for new connections? I tried to add !firstSync right before issue.status.name, but that didn't work. Or should I add som If else? or do you have any clue what I'm I doing wrong here? I have added the whole incoming script below.


        if(issue.status.name == "Closed" || issue.status.name == "Declined" || issue.status.name == "Invalid"){
        return
        }
        
        if(firstSync && replica.project.key == "EFI"){
           issue.projectKey   = "EFI"
           issue.typeName     = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Task"
        }
        if(firstSync && replica.project.key == "EFI"){
           issue.projectKey   = "EFI"
           issue.typeName     = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Task"
        }
        
        issue.summary      = replica.summary
        issue.description  = replica.description
        issue.comments     = commentHelper.mergeComments(issue, replica)
        issue.attachments  = attachmentHelper.mergeAttachments(issue, replica)
        issue.labels       = replica.labels
      8. Ariel Aguilar

        Hi Simone,
        Try the following:

        if(issue.status?.name == "Closed" || issue.status?.name == "Declined" || issue.status?.name == "Invalid"){
        return
        }

        Kind regards,

        Ariel

      9. Simone Svedin

        Hi Ariel Aguilar, now it works like a charm! Thank you so much!! 

      CommentAdd your comment...
    2.  
      1
      0
      -1

      Hello, Simone Svedin 

      If one returns  from the Outgoing sync script before any property is assigned to the replica variable, then no synchronization will happen.
      So in practice, if you add the following to the Outgoing sync script: 

      if (issue.status.name == "Closed") {    log.info("#closed not synchronizing changes on the issue ${issue.key}, since it's ${issue.status.name}")  return
      }

      Regards, Serhiy.

        CommentAdd your comment...