/* * "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." */// specify the issue keydefissueKey='<IssueKeyHere>'// Specify the name of the version to extract from the issuedefversionName='<VersionNameHere>'// Get the issue objectdefresult=get('/rest/api/2/issue/'+issueKey).header('Content-Type','application/json').asObject(Map)// find the version specified on the issue and extract its version defversionReleaseDateString=result.body.fields.fixVersions.find{it.name==versionName}.releaseDate// Parse the extracted date string into a date object that can be set as the due datedefversionReleaseDate=newDate().parse("yyyy-MM-dd",versionReleaseDateString)// Update the issue to set the due date to the extracted versionReleaseDate valuedefupdateDueDate=put("/rest/api/2/issue/${issueKey}").header('Content-Type','application/json').body([fields:[// Set the due date to the versionReleaseDate in the format which Jira expects the date to be induedate:versionReleaseDate.format('yyyy-MM-dd')asString]]).asString()// Check if the issue updated correcly and if so return a success message if(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.