1
0
-1

Team,

I need to sync Sprint from Jira cloud to Jira on-premise (Unidirectional).

I have gone through the below articles and updated the code in both Cloud (Outgoing) and On-premise (Incoming) processors but still, the sprint is not synced to the Jira on-premise. 

https://docs.idalko.com/exalate/display/ED/How+to+sync+sprints+in+Jira+Cloud

https://docs.idalko.com/exalate/display/ED/How+to+sync+sprints+in+Jira+on-premise

After adding the code, i tried to update the Existing sprint goal to trigger the sync but got the below error.



    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hello Yogesh Mude ,

      Please check on the following solution:

      // Sprint synchronisation
      if(entityType == "sprint"){
          // Executed when receiving a sprint sync from the remote side
          // [remoteBoardId:localBoardId] for "one way" Sprint board synchronisation
          // [remoteBoardId:localBoardId, localBoardId:remoteBoardId] for "bi-directional" sync
          def sprintMap = ["3":"5", "5":"3"] 
          // Main Sprint parameters sync
          sprint.name         = replica.name
          sprint.goal         = replica.goal
          sprint.state        = replica.state
          sprint.startDate    = replica.startDate
          sprint.endDate      = replica.endDate
          
          // Target SCRUM Jira Projects Board choice
          def localBoardId = sprintMap[replica.originBoardId]
          if(localBoardId == null){
             throw new com.exalate.api.exception.IssueTrackerException("No board mapping for remote board id "+replica.originBoardId)
          }
          //Set the board ID where the sprint will be created
          sprint.originBoardId = localBoardId 
      }
      // Jira issues synchronisation
      if(entityType == "issue"){
          //Executed when receiving an issue sync from the remote side for the first time
          if(firstSync && replica.project.key == "CSSC"){ // Origin Project Key
              issue.projectKey    = "CSSA" // Target Project Key
              // In case of an Issue Type that is not present in the Target Jira project use "Story" issue type
              issue.typeName      = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Story"
          }
          if(firstSync && replica.project.key == "CSSA"){ // Origin Project Key
              issue.projectKey    = "CSSC" // Target Project Key
              // In case of an Issue Type that is not present in the Target Jira project use "Story" issue type
              issue.typeName      = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Story"
          }
          // Sub-Task Parent Link creation
          // Attention: Parent Issue have to be already synced
          if(firstSync && replica.parentId){
              issue.typeName      = "Sub-task" 
              def localParent     = nodeHelper.getLocalIssueFromRemoteId(replica.parentId.toLong())
              if(localParent){
                  issue.parentId  = localParent.id
              } else {
                  throw new com.exalate.api.exception.IssueTrackerException("Subtask cannot be created: parent issue with remote id " + replica.parentId + " was not found. Please make sure the parent issue is synchronised before resolving this error" )
              }
          }
      
          // Issue fields to synchronize 
          issue.summary       = replica.summary
          issue.description   = replica.description
          issue.comments      = commentHelper.mergeComments(issue, replica)
          issue.attachments   = attachmentHelper.mergeAttachments(issue, replica)
          issue.labels        = replica.labels
          issue.status        = replica.status
          issue.issueLinks    = replica.issueLinks
      
          // Sprint issue linking
          // Sub-Task, in Jira, may not be linked to a Sprint. Only Parent Issue may be linked to Sprint
          if (issue.typeName != "Sub-task"){ 
              def remoteSprintId = replica.customFields.Sprint?.value?.find { it.state.toUpperCase() != "CLOSED" }?.id
              if(remoteSprintId){
                 def localSprintId = nodeHelper.getLocalIssueKeyFromRemoteId(remoteSprintId, "sprint")?.id
                   if(localSprintId){
                      issue.customFields.Sprint.value = localSprintId
                  }
              }
              
              // Epic sync 
              Epic.receive()
          }
      }


      With best regards,
      Dmitrij

        CommentAdd your comment...