Sprint Status Closed

Originally asked by Stefan Ernst on 22 December 2021 (original question)


Hello,

the sprint sync script from the documentation does not account for the local sprint being closed:

def remoteSprintId = replica.customFields.Sprint?.value?.find { it -> it.state.toUpperCase() != "CLOSED" }?.id
    if(remoteSprintId){
       def localSprintId = nodeHelper.getLocalIssueKeyFromRemoteId(remoteSprintId, "sprint")?.id
         if(localSprintId){
            issue.customFields.Sprint.value = localSprintId
        }
    }

If localSprint is closed then exalate will throw the following error:

services.jcloud.exception.UpdateIssueJiraCloudException: Could not update issue

because Closed sprints cannot be assigned to issues. How to solve this here?


Answer by Iona Matheron on 23 March 2023

I resolved my issue. I found that the below script gives me the sprint Id

def remoteSprintId = replica.customFields.Sprint?.value?.find { it -> it.state.toUpperCase() != “CLOSED” }?.id
if(remoteSprintId){
issue.customFields.“Sprint”.value = remoteSprintId.toLong()
}


Answer by Iona Matheron on 20 March 2023

Hi, I have issue with sync sprints as well

https://docs.exalate.com/docs/how-to-sync-sprints

this part

def remoteSprintId = replica.customFields.Sprint?.value?.find { it -> it.state.toUpperCase() !=``"CLOSED" }?.id

always come up as null

Has anyone here ever had a working sync sprint script for Cloud?

Thanks


Answer by Jonathon Sisson on 06 March 2023

Did you ever find a solution for this issue?


Comments:

Jonathon Sisson commented on 09 August 2023

Using this snippet I have been able to at least check if the sprint is currently closed which helped a lot with dealing with this issue:

def remoteSprintId = replica.customFields.Sprint?.value?.find { it.state.toUpperCase() != "CLOSED" }?.id
if(remoteSprintId){
  
        def localSprintId = nodeHelper.getLocalIssueKeyFromRemoteId(remoteSprintId, "sprint")?.id
        if(localSprintId){
            def currentState = httpClient.get("/rest/agile/1.0/sprint/"+localSprintId)?.state?.toLowerCase()
if(currentState && currentState != "closed"){
                issue.customFields.Sprint.value = localSprintId
            }
        }       
    }