Bulk update the resolution of all issues returned from the JQL search which meet the specified conditions.
As a Jira admin, I want to change the resolution of a large number of issues which were mislabeled.
I can use this script to update the resolution of all these issues to their corresponding one (like "Duplicate").
Good to Know
You can use this code as part of a larger script to update the issues resolution based on additional logic.
You can look up the available resolution names in "Jira Settings" > "ISSUE ATTRIBUTES" > "Resolutions".
// Define a JQL query to search for the issues on which you want to update the resolution
final jqlQuery = "project = TEST AND issueType = Bug"
// The Name of the resolution to be set
def resolutionName = 'Duplicate'
// Search for the issues we want to update
def searchReq = get("/rest/api/2/search")
// Verify the search completed successfully
assert searchReq.status == 200
// Save the search results as a Map
def searchResult = searchReq.body as Map
def issues = searchResult.issues as List