You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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.
I agree with what @Fabio Racobaldo _Herzum_ told you.
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.