1
0
-1

How to sync Sprints from Azure DevOps to Jira? may be updating iteration path from azure to Jira sprint field?



any help thank you.

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi,


      I have just completed the use case of syncing a sprint to Jira dynamically i.e. if a new sprint is created and assigned to a workItem, it should be created on Jira side with the same information. The following code snippets achieve this:


      Azure DevOps Outgoing Script
      def res = httpClient.get("/<<project_name>>/<<team_name_in_ADO>>/_apis/work/teamsettings/iterations",true)
      def flag = 0
      int i = 0
      for (;i<res.value.size(); i++){
          if (res.value[i].path == replica.iterationPath){
              flag =1
              break
          }
      }
      if (flag == 1){
          replica.customKeys."sprint_name" = res.value[i].name
          replica.customKeys."sprint_start" = res.value[i].attributes.startDate
          replica.customKeys."sprint_end" = res.value[i].attributes.finishDate
      }
      Jira Cloud Incoming Script
      //the following code segment uses board id=3. 
      //please change that as per your requirements
      //or create a mapping using a HashMap
      def list = httpClient.get("/rest/agile/1.0/board/3/sprint")
      int flag = 0
      for (int i=0; i<list.values.size(); i++){
          if (list.values[i].name == replica.customKeys.'sprint_name')
              flag = 1
      }
      String startDate, endDate;
      if (flag == 0){
          if (replica.customKeys."sprint_start"){
              startDate = replica.customKeys."sprint_start".trim()
              startDate = startDate.replaceAll("Z",".000+05:00").trim();
          }
          if (replica.customKeys."sprint_end"){
              endDate = replica.customKeys."sprint_end".trim()
              endDate = endDate.replaceAll("Z",".000+05:00").trim();
          }
          def res = httpClient.post("/rest/agile/1.0/sprint", "{\"name\": \"${replica.customKeys.'sprint_name'}\", \"startDate\": \"${startDate}\", \"endDate\": \"${endDate}\", \"originBoardId\": 3}")
      }
      def res = httpClient.get("/rest/agile/1.0/board/3/sprint")
      for (int i=0; i<res.values.size(); i++){
          if (res.values[i].name == replica.customKeys.'sprint_name')
              issue.customFields.Sprint.value = res.values[i].id
      }        

      The attached video shows the script in action. 


      Thanks

      Majid

        CommentAdd your comment...