Bhavya-org / Scripts

0 stars 0 forks source link

Remove story points when issue type changes #39

Open Bhavya-ss opened 2 weeks ago

Bhavya-ss commented 2 weeks ago

def issueKey = issue.key logger.info("Issue Key: " + issueKey) def storyPoints = issue.fields.customfield_10035 logger.info("Current Story Points: " + storyPoints)

for (item in changelog.items) { logger.info("Changelog Item Field: " + item.field) if (item.field == "issuetype") { // Check if storyPoints is not null before attempting the update if (storyPoints != null) { def updateData = [ fields: [ customfield_10035: null // Set story points to null ] ]

        def response = put("/rest/api/2/issue/${issueKey}")
            .header('Content-Type', 'application/json')
            .body(updateData)
            .asString()

        logger.info("Response Status: " + response.status)
        logger.info("Response Body: " + response.body)

        if (response.status == 204) {
            return 'Success: Story points updated to null'
        } else {
            return "Error updating story points: ${response.status}: ${response.body}"
        }
    } else {
        logger.info("Story points are already null")
        return 'Story points are already null'
    }
}

}