Hello everyone. We have a number of issues with a given status. I would like to change their status when they have been inactive for a given period of time.
Is it possible to create a script in scriptrunner that can do exactly this?
Yes this would be possible to be created in Scriptunner under "Job". I mean this script should run e.g. everyday at midnight and gather all issues which satisfy your conditions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have something like this, it looks if the issue is more than 6 months inactive:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.search.SearchResults
import com.atlassian.jira.web.bean.PagerFilter
import org.joda.time.DateTime
// Get the Jira Service Desk instance
def jira = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
// Get the project key
def projectKey = "MY_PROJECT_KEY"
// Get all issues in the project that have a status different than resolved
def searchResults = ComponentAccessor.searchProvider.search("project = '" + projectKey + "' and status != 'Resolved'", jira, PagerFilter.getUnlimitedFilter())
// Get all the issues
def issues = searchResults.getIssues()
// Define date 6 months ago
def sixMonthsAgo = new DateTime().minusMonths(6)
// Iterate through all issues and change status if inactive for 6 months
for (Issue issue : issues) {
def lastComment = issue.getComments().last()
if (!lastComment || lastComment.getCreated().toDate() < sixMonthsAgo.toDate()) {
issue.setStatus("Resolved")
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Søren Hansen ,
in order to transition an issue in a different status you have not to set status on the issue.
You need to use the following api https://docs.atlassian.com/software/jira/docs/api/8.1.0/com/atlassian/jira/workflow/WorkflowManager.html#migrateIssueToWorkflow-com.atlassian.jira.issue.MutableIssue-com.atlassian.jira.workflow.JiraWorkflow-com.atlassian.jira.issue.status.Status-
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online 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.