Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Completing a Sprint doesn't count as an issue update

Paul Madison
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 13, 2023

We are having an issue with our reporting where jira issues have a last updated date before the date a sprint was completed.

 

Is there a way to update all of our Jira issues in sprints after the sprints are completed?

2 answers

1 accepted

0 votes
Answer accepted
Paul Madison
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 16, 2023

I ended up using a Script Listener (Using Scriptrunner) with the following code.  The code will edit a field on the issue, so that the ticket is updated.

 


////  Sprint Closed Event
////  All Projects

// get board and sprint info
def getBoardResponse = get("/rest/agile/1.0/board/${sprint.originBoardId}").asObject(Map)
assert getBoardResponse.status == 200
def board = getBoardResponse.body

// log sprint info
logger.info("Sprint '{}' with id: {} has been closed. Its origin board is: '{}' with type: {}", sprint.name, sprint.id, board.name, board.type)

// get sprint issues
def sprintIssues = get("/rest/agile/1.0/sprint/${sprint.id}/issue").asObject(Map)

//set variables for looping
int maxResults = sprintIssues.body['maxResults']
int totalIssues = sprintIssues.body['total']
int startAt = 0
def issueKey = "key"
def newvalue = 'trigger update from Script Listener'
final customField = 'customfield_12345'  // add custom field id here

// loop through issues and update them
for (startAt = 0; startAt < totalIssues;)  // loop through pagination
{
    // if on the last call, adjust the maxResults variable to only loop the correct number of times
    if (totalIssues - startAt < maxResults)
    {
        maxResults = totalIssues - startAt
    }
   
    // loop through each issue
    for (int i = 0 ; i < maxResults; i++)
    {
        //get issue key
        issueKey = sprintIssues.body['issues'][i]['key']
       
        //update issues, update Reporter Company field
        put("/rest/api/2/issue/${issueKey}")
            .header('Content-Type', 'application/json')
            .body([
            fields: [
                    (customField): newvalue
                ]
            ]).asString()
    }
   
    // get next set of data (pagination)
    startAt = startAt + maxResults
    sprintIssues = get("/rest/agile/1.0/sprint/${sprint.id}/issue?startAt=" + startAt).asObject(Map)
    if(sprintIssues.status != 200)
    {
        break
    }
}
0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 13, 2023

Hi @Paul Madison 

What problem are you trying to solve by doing that?  Knowing that may help the community to suggest ideas to solve that problem.

In the meantime, you could create an automation rule, triggered on sprint completion, which makes an update to the issues in the sprint (e.g., add a comment).

Kind regards,
Bill

Paul Madison
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 13, 2023

we have a tool that scrapes data from Jira every night and put it into a database for BI reporting.  The tool only pulls tickets that are updated that day, so if a jira issue is completed before the sprint is completed, the data in the jira issue still shows it is in an open sprint, unless we update the issues after closing the sprint.

 

I've looked at the "Sprint Completed" automation rule and it is limited to one board, so we would have to create an automation for each board.  This isn't practical for us.

 

I found something in Scriptrunner I might be able to use, so I'll look at that.

Like Bill Sheboy likes this
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 13, 2023

Yes, that is the current behavior. 

I recall seeing a suggestion to make the sprint-related triggers more generic, allowing them to be used in global rules for Premium license customers.  (That may not be an option for Free and Standard license users, as the limits of global rule execution would quickly use up their execution limits.)

Like Paul Madison likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events