Do Scriptrunners "Scripted Fields" Cause Much Server Load?

Seb Kouba February 24, 2015

We are starting to use scripted fields more and more and I was curious about the server load this may cause. Is it anything to worry about? Currently we use 1-2 scripted fields per issue in a system with 33k issues and I haven't noticed any problems whatsoever.

Thanks for your time.

1 answer

1 accepted

1 vote
Answer accepted
JamieA
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 24, 2015

It depends what you do with them. It's really impossible to say much more without knowing what your code does.

You could time a full reindex with and without the script fields... the time difference will give you a very basic idea of the amount of additional work they are doing.

But in terms of ability to blow yourself up, script fields are at the more dangerous end of the spectrum. Novices should probably steer clear until they are familiar with jira, and the API.

 

Seb Kouba February 26, 2015

Hi Jamie,

thanks for the super fast reply! I'll take it into consideration and make sure we are careful when there is no way around scripted fields.

We use the scripted fields to pass Cost ID values along Issue Links. We have a three / four level issue hierarchy and the Cost ID is entered at the top and inherited from there.

This is the cost ID script, the others are only a few line. This is more for information, obviously I can't expect a code review...

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.customfields.view.CustomFieldParams
import com.atlassian.jira.issue.link.LinkCollection;
import com.atlassian.jira.issue.link.IssueLinkType;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
String second = "Cost-ID not defined"
if (issue.issueTypeObject.name == "Sub-Task") {
	if (issue.parentObject != null) {
		if (issue.parentObject.issueTypeObject.name == "Demand Task") {
			def Issue parent = issue.parentObject;
			def field2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Project Cost-ID");
			def String type = parent.getCustomFieldValue(field2);
			if (type == null) {
				CustomField cf = customFieldManager.getCustomFieldObjectByName("Client Cost-ID");
				Map cfVal = parent.getCustomFieldValue(cf) as Map;
				if (cfVal) {
					second = cfVal.get("1");
				}
			} 
			else{
				def field3 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Project Cost-ID");
				second = issue.parentObject.getCustomFieldValue(field3);
			}
		}
		else{
			def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Cost-ID");
	        second = issue.parentObject.getCustomFieldValue(field);
		}
		
	} 
	
}
if ((issue.issueTypeObject.name == "EPIC Task")||(issue.issueTypeObject.name == "Implementation Task")||(issue.issueTypeObject.name == "Activity")) {
List inwardIssues = ComponentAccessor.getIssueLinkManager().getLinkCollectionOverrideSecurity(issue).getInwardIssues("Hierarchy");
if ((inwardIssues != null) && (inwardIssues.size() == 1)) {
  def parent = inwardIssues[0];
  def field2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Project Cost-ID");
  def String type = parent.getCustomFieldValue(field2);
  if (type == null) {
	CustomField cf = customFieldManager.getCustomFieldObjectByName("Client Cost-ID");
	Map cfVal = parent.getCustomFieldValue(cf) as Map;
		if (cfVal) {
			second = cfVal.get("1");
		} 
	} else {
		def field3 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Project Cost-ID");
        second = parent.getCustomFieldValue(field3);
	}
	
}  
}

if ((issue.issueTypeObject.name == "Defect")||(issue.issueTypeObject.name == "User Story Task")) 
{
List inwardIssues = ComponentAccessor.getIssueLinkManager().getLinkCollectionOverrideSecurity(issue).getInwardIssues("Hierarchy");
if ((inwardIssues != null) && (inwardIssues.size() == 1)) {
  def parent = inwardIssues[0];
  def field =  ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Cost-ID");
  second = parent.getCustomFieldValue(field);
} 
}   
return second;
JamieA
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 27, 2015

I don't think that's a problem. What I would look for is things like connecting to external databases etc... only way of telling though is with a profiler.

Suggest an answer

Log in or Sign up to answer