# How to Sync Sprint from Azure devops To Jira

**URL:** <https://community.exalate.com/t/how-to-sync-sprint-from-azure-devops-to-jira/4289>\
**Category:** General Questions\
**Tags:** exalate, usecase, migrated\_question, sprint\
**Created:** [November 4, 2024, 6:45am UTC](https://community.exalate.com/t/how-to-sync-sprint-from-azure-devops-to-jira/4289 "2024-11-04T06:45:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 6:45am UTC](https://community.exalate.com/t/how-to-sync-sprint-from-azure-devops-to-jira/4289/1 "2024-11-04T06:45:05Z")

</div>

_Originally asked by Harinder Singh on 23 July 2020 [(original question)](https://oldcommunity.exalate.com/questions/11340942)_

* * *

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

any help thank you.

* * *

---

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 6:45am UTC](https://community.exalate.com/t/how-to-sync-sprint-from-azure-devops-to-jira/4289/2 "2024-11-04T06:45:06Z")

</div>

_Answer by Syed Majid Hassan on 24 September 2022_

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** Expand source

```auto
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** Expand source

```auto
//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](http://community.exalate.com) shows the script in action.

Thanks

Majid

* * *
