Hi,
I want to set issue priority in JIRA Ticket using groovy. We have a drop down list in JIRA ticket which is populated with a default priority once an issue is created. e.g "Priority 6".
With the help of groovvy I want to set the priority as "Priority 4".
I am able to get the issue priority using the following code, but not able to set a new priority:
def priority=issue.priorityObject.name;
for setting:
issue.setPriority(new priority);
giving below error:
No signature of method: com.atlassian.jira.issue.IssueImpl.setPriority() is applicable fo
r argument types: (java.lang.String) values: [ Priority 4]
Possible solutions: setPriority(org.ofbiz.core.entity.GenericValue), getPriority(), setPriorityId(java.lang.String)
at Script480.run(Script480.groovy:66)
Pls suggest
Hi Hemanshu,
Try something like
def priority4 = "Priority 4" def priorityToSetId = ComponentAccessor.getConstantsManager().getPriorityObjects().find {it.name == priority4}?.getId() if (! priorityToSetId) log.debug "Could not find priority with name: $priority4" issue.setPriorityId(priorityToSetId)
regards, Thanos
Hi Thanos, still not working:
This is my code:
def mail_priority=descArr[19].substring(9);//this is fetching string from a line. The string in this case is "Priority 4"
def final_priority=mail_priority.toString();//converting to String
def priorityToSetId = ComponentAccessor.getConstantsManager().getPriorityObjects().find {it.name == final_priority}?.getId();
if (! priorityToSetId)
log.debug "Could not find priority with name: $final_priority"
log.debug("Setting Priority");
issue.setPriorityId(final_priority);
pls suggest
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I suppose this is a post function and is before the store issue step right ?
Also do you get any errors ? What about the debug messages in your logs ?
JIRA and SR versions ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thanos,
This is part of a script which parses the content of an incoming email in JIRA to field values in Jira.
Hence this code is a post function which is part of transition:
*-------> Tier 1 New
this code:
def mail_priority=descArr[19].substring(9);//this is fetching string from a line. The string in this case is "Priority 4"
def final_priority=mail_priority.toString();//converting to String
def priorityToSetId = ComponentAccessor.getConstantsManager().getPriorityObjects().find {it.name == final_priority}?.getId();
if (! priorityToSetId)
log.debug "Could not find priority with name: $final_priority"
log.debug("Setting Priority");
issue.setPriorityId(final_priority);
is fecthing priority from the email(as Priority 4) and parsing the same with the "Priority" field in JIRA whose default value is set up as "Priority 6".
I cannot find any error in logs, but now after ticket creation, the priority field disappears.
Hence, there is no value set for "Priority" field in JIRA during ticket creation.
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.