I have a one-off use case where I have issues under a specific epic and want to remove attachments for all stories under that epic.
I do have script runner but have not found an example to accomplish this task.
Appreciate any help that can be provided.
You might find this video useful - https://youtu.be/ebImmxh_2Yw
I also recently found this video but did not have automation installed yet. We are in the process of testing 9.4 and the automation built into JIRA and this method did work.
I also worked with Scriptrunner on an older script that does work as well.
import com.atlassian.jira.bc.issue.search.SearchService // <-- add new import
import com.atlassian.jira.issue.MutableIssue; // <-- add new import
// more imports
import com.atlassian.jira.component.ComponentAccessor
def findIssues(String jqlQuery) {
def issueManager = ComponentAccessor.issueManager
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser) // <-- changed here
def searchService = ComponentAccessor.getComponent(SearchService) // <-- changed to Search Service
def query = jqlQueryParser.parseQuery(jqlQuery)
def search = searchService.search(user, query, PagerFilter.getUnlimitedFilter()) // <-- changed here
search.results.collect { issue ->
issueManager.getIssueObject(issue.id)
}
}
def attachmentManager = ComponentAccessor.getAttachmentManager()
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def jqlQuery = "your-jql-query"
def issues = findIssues(jqlQuery)
issues.each{issue ->
def attachments = attachmentManager.getAttachments((MutableIssue) issue) // <-- typecast it to MutableIssue
attachments.each {attachment ->
attachmentManager.deleteAttachment(attachment)
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.