1
0
-1

Hi Team,

We are using Exalate connect option to sync existing Jira issue with existing github issues/PR's.
When we sync with Github we have below script placed in Jira incoming script.

issue.customFields."GITHUB ID".value = replica.key
issue.customFields."GitHub Status".value = replica.status.name
issue.customFields."Github link".value = remoteReplica.payload.issueUrl

These above field values not syncing immediately after the first sync.

--------------------------------------------------------
Jira incoming script

--------------------------------------------------------


if(firstSync){
  syncHelper.syncBackAfterProcessing()

issue.projectKey   = "SWDEV" 
   // Set type name from source issue, if not found set a default
//issue.typeName     = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Defect"
//}
//issue.summary      = replica.summary
//issue.description  = replica.description
issue.customFields."GITHUB ID".value = replica.key
issue.customFields."GitHub Status".value = replica.status.name
issue.customFields."Github link".value = remoteReplica.payload.issueUrl



------------------------------------------------------------------------------------------------

Github Incoming script

------------------------------------------------------------------------------------------------


if(firstSync){
issue.repository   = "amd-trial/DemoEx"
}
issue.summary      = replica.summary
issue.description  = replica.description
issue.comments     = commentHelper.mergeComments(issue, replica)


/*
Status Synchronization


Sync status according to the mapping [remote issue status: local issue status]
If statuses are the same on both sides don"t include them in the mapping
def statusMapping = ["Open":"New", "To Do":"Open"]
def remoteStatusName = replica.status.name
issue.setStatus(statusMapping[remoteStatusName] ?: remoteStatusName)
*/
issue.labels       = replica.labels
issue.assignee     = nodeHelper.getUserByUsername(replica.assignee?.username)
issue.reporter     = nodeHelper.getUserByUsername(replica.reporter?.username)



---------------------------------------------------------------------------------------------------
Please help with your inputs on this

    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      Hi Varun Joseph Allu 


      Hope you are doing good. Sorry for the late response.


      Can you please try to move following line from if(firstSync) to outside the if block?:



      syncHelper.syncBackAfterProcessing()
      

      I mean, do not put above line in if(firstSync) condition, because for connect operation, firstSync condition will not satisfied first time.


      Thanks,

      Sonal

      1. Sonal Otwani

        Hi Varun Joseph Allu 


        Hope you are doing good.


        Can you please update us for my previous comment?


        Thanks,

        Sonal

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

      Hi Varun,


      Thanks for reaching us! 


      Initially it should be possible to sync Github fields to Jira customfields as long as the value of both fields match.


      In order to understand what is failing in your current configuration please confirm the following:


      1. What is the value type of the customfields created in Jira, do they match the type of value being passed by the fields from Github?
      2. I see you are using syncHelper.syncBackAfterProcessing() according to this documentation the issue.key customfield script should be set on the incoming script of the opposite side. Have you tried this implementation?


      Additionally, could you also share the scripts from the outgoing sync? 


      Thanks,


      1. Varun

        Hi Ezequiel Consorti ,

        Thanks for your response.

        Here are the details steps :


        • Trying sync between Jira and Github with Connect option in Jira
        • After exalating with github.
        • We are expecting two fields to be updated immediatly in Jira with github status and github url for that we are using the below script
        issue.customFields."GITHUB ID".value = replica.key
        issue.customFields."GitHub Status".value = replica.status.name
        issue.customFields."Github link".value = remoteReplica.payload.issueUrl
        • But the fields were not syncing immediately in Jira after first sync.
        • If we update or comment in Github these fields were updating with the details.
        • We are not expecting this,we are expecting the details to be synced in the first sync itself.


        Can we achieve this ?


        Thank you,
        Varun



      2. Ezequiel Consorti

        Hi varun,


        I understand from looking at your scripts that the syncs are happening from Github to Jira.


        I see that in your Jira scripts you have 

        if(firstSync){
          syncHelper.syncBackAfterProcessing()
        } 

        This line of code helps to send back certain information to the source side once the issue is created on the destination side.

        If what you wish to do is to set customfields from Github to Jira on the first sync, you would need to add the script for those customfields inside the if(firstSync){}.


        Additionally I see you are using the syncHelper but I do not see any customfield being shared back to github, because of this I believe that there is no need for the syncHelper in the Jira incoming scripts. More info on how this helper works.


        Thanks,
        Ezequiel

      3. Varun Joseph Allu

        Hi ,


        did we have a solution for this ?


        sync back is not working as expected.


        Thank you,

        Varun

      CommentAdd your comment...