/* * "This script console script can be ran on the Script Console inside of Jira Cloud to show how you can select the release date for a specified version and set the due date to this date. * All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner * license shall be granted a non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed * or amended and must be included in any circumstances where the code snippet is shared by You or a third party." *///specifytheissuekey
defissueKey='<IssueKeyHere>'//Specifythenameoftheversiontoextractfromtheissue
defversionName='<VersionNameHere>'//Gettheissueobject
defresult=get('/rest/api/2/issue/'+issueKey).header('Content-Type','application/json').asObject(Map)//findtheversionspecifiedontheissueandextractitsversiondefversionReleaseDateString=result.body.fields.fixVersions.find{it.name==versionName}.releaseDate
//Parsetheextracteddatestringintoadateobjectthatcanbesetastheduedate
defversionReleaseDate=newDate().parse("yyyy-MM-dd",versionReleaseDateString)//UpdatetheissuetosettheduedatetotheextractedversionReleaseDatevalue
defupdateDueDate=put("/rest/api/2/issue/${issueKey}").header('Content-Type','application/json').body([fields:[//SettheduedatetotheversionReleaseDateintheformatwhichJiraexpectsthedatetobein
duedate:versionReleaseDate.format('yyyy-MM-dd')asString
]]).asString()//Checkiftheissueupdatedcorreclyandifsoreturnasuccessmessageif(updateDueDate.status==204){return"Due date succesfully Updated"}else{return"Failed to find issue: Status: ${result.status} ${result.body}"}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.