Script runner help for scripting about field values

B4st13n February 1, 2017

I realize I really dont understand the documentation about JIRA Script runner because there is absolutely no example of what I'm looking for. Could you help me ?

I'm looking for 2 scripts.

  1. Change the priority of an issue by detecting the a word in the description. I don't know how to get the description and how to do a contains search. I would like to change the priority to urgent when the description contains the "urgent" word.
  2. Copy the story points value to the original estimate. I would like to copy story points to days with a velocity factor. Velocity can be hardcoded for this first version. Each point is a day * velocity.

Thank you.

 

2 answers

2 votes
Alina Fecheta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 1, 2017

Hello, 

Story points is a custom field. You can access it like this:

 

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
 
 
CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager();
  
CustomField customField_name = customFieldManager.getCustomFieldObjectByName( "customfield_name" );
customfield_value = issue.getCustomFieldValue( customField_name))
The original estimate can be set like this:
issue.setEstimate(Long estimate)  //estimate should be given in seconds
0 votes
B4st13n February 1, 2017

I finally found hoe to set the priority

 

import com.atlassian.jira.issue.MutableIssueif (issue.summary.contains("Urgent") || issue.summary.contains("URGENT")) {    MutableIssue mutableIssue = (MutableIssue) issue;    mutableIssue.setPriorityId("2");}

I'm sill looking for my point two.

B4st13n February 2, 2017

I hate people that downvote without explanation. Then what? Doesn't help at all.

Alina Fecheta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2017

I know, especially when someone fixes their own problem.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events