Example scripts
To homepage
Jira

Archive work items returned by a JQL Search
App in script

ScriptRunner For Jira
by Adaptavist
Compatibility

Jira
Language |
groovy
// Construct the JQL to return the work items to be archived
def jqlQuery = "updated >= '-30d' and project = 'RRR'"
// Loop over each work item
def archivedWorkItems = WorkItems.search(jqlQuery).take(500).collect { workItem ->
// Archive the current work item
def archiveWorkItem = put("/rest/api/3/issue/archive")
.header("Content-Type", "application/json")
.body(
issueIdsOrKeys: [workItem.key]
)
.asObject(Map)
// Validate the work item was archived correctly
assert archiveWorkItem.status >= 200 && archiveWorkItem.status < 300
workItem.key
}
logger.info("The following work items were archived succesfully: ${archivedWorkItems}")Having an issue with this script?
Report it here