1
0
-1

Hello,

I would like to integrate Jira and Azure DevOps. I configured outgoing groovy script to send data to DevOps.


replica.key            = issue.key
replica.type           = issue.type
replica.assignee       = issue.assignee
replica.reporter       = issue.reporter
replica.summary        = issue.summary
replica.description    = issue.description
replica.labels         = issue.labels
replica.comments       = issue.comments
replica.resolution     = issue.resolution
replica.status         = issue.status
replica.priority       = issue.priority
replica.attachments    = issue.attachments
replica.project        = issue.project
replica.parentId       = "125718"


Work item on DevOps site is created correctly in project.

I would like to update one more field in DevOps.  

In section "Related Work" I would like to add parent to created item. I have parent id == 125718.

In code I' trying something like that but it doesn't work:

replica.parentId       = "125718"

Can you give me some advice how I should do it?

    CommentAdd your comment...

    4 answers

    1.  
      1
      0
      -1

      Syed Majid Hassan 

      We configured the connection and now it works. We have a problem though. When we copy a comment from Jira to DevOps, Exalate sets the author of the comment to a proxy user on the DevOps side. We would like to change this behavior. We have found a code snippet but it has a hard-coded email address and we would like to have this work dynamically. Can you help us with how we should modify this snippet to work so it would use the actual user who made a comment?

      1. Syed Majid Hassan

        Sure Darek

        Can you please share the code snippet you are using please?
        Also, are all users replicated between Jira and DevOps? Do they have the same usernames/ email addresses?


        Thanks

        Majid


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

      Hi Syed Majid Hassan


      Can you help me to get value from single group picker Jira custom field? 

      When I used issue.customFields."Support Group"?.value?.value like for select list the result is 'null'

      1. Syed Majid Hassan

        Hi Darek,


        I would need more information than that to be able to resolve this issue.

        However, on the face of it here are my observations:


        1. issue.customFields."Support Group"?.value?.value looks ok, but depends on where you are using it. 
        2. If it is giving null, the value selected is probably null. 
        3. Assuming that you are trying to send this field from Jira to Azure Devops (ADO), the recommendations would be the following:
          • Outgoing on Jira: replica.customFields."Support Group" = issue.customFields."Support Group"
          • Incoming on ADO: debug.error(replica.customFields."Support Group"?.value.value)
        4. Once the above scripts have been added, please trigger a change from Jira ticket and monitor the errors screen in ADO Exalate panel. You should receive the value of the Jira field in the errors screen. 
        5. Once you do step 4 successfully, then you can assign the received data to any ADO field of your liking. 


        Here is a small video demonstrating the approach:

        Sync select list from Jira to ADO.mp4


        Please let me know if you have any questions. 


        Thanks

        Syed


      CommentAdd your comment...
    3.  
      1
      0
      -1

      Hi Darek,


      Thank you for taking the time on our call earlier today. I have finalized the testing and come up with the cleanest way to do this. Here are my final scripts:


      Outgoing on JIRA side:

      replica.customKeys."Support Group" = issue.customFields."Support Group"?.value?.value

      This is in line with my approach of sending the Support Group over, but you could change that to send the static value of parent ticket on ADO side as well (like you were doing originally):

      replica.customKeys."X" = "125718"


      Incoming on ADO side:

      if(firstSync){
         // Set type name from source entity, if not found set a default
         workItem.typeName = nodeHelper.getIssueType(replica.type?.name)?.name ?: "Task";
         if (replica.customKeys."Support Group" == "HR")
          {
              workItem.parentId = "https://dev.azure.com/exalatedemo/Some%20Project/_workitems/edit/{parent workItem of HR group}"
              workItem.comments = commentHelper.addComment("Added this to parent", false, workItem.comments)
          }
          else if (replica.customKeys."Support Group" == "IT")
          {
              workItem.parentId = "https://dev.azure.com/exalatedemo/Some%20Project/_workitems/edit/{parent workItem for IT group}"
              workItem.comments = commentHelper.addComment("Added this to parent", false, workItem.comments)
          
          }
          else if (replica.customKeys."Support Group" =="Finance")
          {
              workItem.parentId = "https://dev.azure.com/exalatedemo/Some%20Project/_workitems/edit/8183/{parent workItem for Finance group}"
              workItem.comments = commentHelper.addComment("Added this to parent", false, workItem.comments)
          
          }
          workItem.comments = commentHelper.mergeComments(workItem, replica)
      }


      In the above approach, I pick the value of Support Group and then assign this newly created ticket to be a child of the workItem (based on your mappings). We conclude by adding a small comment to the ticket as well. 


      Here is a short video showing this approach in action:


      Optimatis Parent Child ADO Jira.mp4


      Please let me know if you have any further questions on this. 


      Thanks

      Majid

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

        Hi Darek,


        as I know, you need to transform the incoming "JIRA-Issue-Key"
        to the Azure DevOps "WorkItem-ID".


        In incoming script on Azure DevOps side you should use:


        if (replica.parentId) {
           def localParent = syncHelper.getLocalIssueKeyFromRemoteId(replica.parentId.toLong())
           if (localParent) {
              workItem.parentId = localParent.id
           }
        }


        With this block, the local workItem with the replica ID will be pulled and assigned


        Kind Regards


        Stefan

          CommentAdd your comment...