good afternoon I'm creating a script so when an IM is opened it sets the priority according to the summary, where if the summary contains p2 it creates the Im with Medium priority, but it's only creating with low priority, follow the script
import groovy.json.JsonSlurper;import groovy.json.StreamingJsonBuilder;import com.atlassian.jira.component.ComponentAccessor;import com.atlassian.jira.project.Projectimport java.net.URLimport java.net.URLEncoderimport com.atlassian.jira.issue.label.LabelManager
// veifica se não tem label de OpsgenieLabelManager labelManager = ComponentAccessor.getComponent(LabelManager)def labels = labelManager.getLabels(issue.id).collect{it.getLabel()}def issuetype = issue.getIssueType().name;
def projeto = issue.getProjectObject().getKey()if(projeto == "SDTEST"){ def priorityP2 def priorityP1 if(issue.getSummary().contains("P2")) priorityP2 = "Medium" if(issue.getSummary().contains("P1")) priorityP1 = "High"}
Hi @[deleted]
in case the script is not a hard requirement you likely could do this using automation which comes without any additional cost in your plan.
The rule could look like this:
You can learn more about Automation in Jira here:
Regards,
Daniel
Bom dia Daniel, tudo bem ?
Eu fiz essa automação porem em alguns momentos ela falha não alterando a prioridade por isso pensei em fazer via script
import com.atlassian.jira.component.ComponentAccessor;import com.atlassian.jira.event.type.EventDispatchOption;import com.atlassian.jira.issue.UpdateIssueRequest;import com.atlassian.jira.config.PriorityManager
def issuetype = issue.getIssueType().name;def customFieldManager = ComponentAccessor.getCustomFieldManager()def issueManager = ComponentAccessor.getIssueManager()def userLogged = ComponentAccessor.getJiraAuthenticationContext().loggedInUser
def currentPriority = issue.getPriority().getId() //return the ID of the priority of the issuedef projeto = issue.getProjectObject().getKey()log.info("kEY - " + issue.key)log.info("Prioridade Atual- " + currentPriority)
switch(projeto == "SDTEST" && issuetype == "Incident"){
case issue.getSummary().contains("P2"): issue.setPriorityId("7") // 7 é o id da priority Medium break case issue.getSummary().contains("P1"): issue.setPriorityId("10002") // 10002 é o id da priority High break } log.info("Nova Prioridade - " + issue.getPriority().getId())
issueManager.updateIssue(userLogged, issue, EventDispatchOption.DO_NOT_DISPATCH, false);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@[deleted] -
Please verify the following items -
1)Ensure that the priority scheme associated with your project has "Medium" as an option. Is there a default option set against the priority scheme? I am sure the default option is "Low".
2) Your code seems to be incomplete - It seems you only populated the local variable prorityP1 and priorityP2. You still need to have calls setting the issue priority field (example - setPriorityId("") ) and update the issue.
Hope this helps.
Best, Joseph Chung Yin
Jira/JSM Functional Lead, Global Infrastructure Applications Team
Viasat Inc.
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.