JIRA Groovy Script - How To Change Priority Of An Issue

Do you like this?

Summary:
This script shows you how to change priority of an issue.


Content:

Suppose we have an issue with its key "Issue_Key".

import org.ofbiz.core.entity.GenericValue;

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.config.ConstantsManager;
import com.atlassian.jira.config.PriorityManager;
import com.atlassian.jira.config.ResolutionManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.priority.Priority;

ComponentManager cm= ComponentManager.getInstance()
IssueManager im= cm.getIssueManager()
MutableIssue issue=im.getIssueObject("Issue_Key")

PRIORITY_TRIVIAL_NAME= "Trivial"

ConstantsManager constants= cm.getConstantsManager()
GenericValue PRIORITY_TRIVIAL= constants.getPriorities().findAll { it.name == PRIORITY_TRIVIAL_NAME }.pop()

issue.setPriority(PRIORITY_TRIVIAL)
issue.store()

 
comments powered by Disqus