+import com.atlassian.jira.issue.label.Label
+// Define the date before which the issues should be archived (01/01/2018)
+def dateBefore = Date.parse("yyyy-MM-dd", "2024-10-30")
+// Define the JQL query to find issues that are Resolved and created before 01/01/2018
+def jqlQuery = "status = Resolved AND created < '${dateBefore.format('yyyy-MM-dd')}'"
+Issues.search(jqlQuery).each { issue ->
+ Set<Label> labels = issue.getLabels()
+ if(!("archived" in issue.labels*.label) && !issue.isArchived()){
+ // No label and issue not recognised in the system as being archived
+ log.error("Archiving ${issue.key}");
+ //Transition to Archived
+ //issue.transition('Archived')