When running Groovy scripts, JMCF makes contextual information available to your script through built-in variables and functions. This document details them. Note that you can also define custom variables in your Groovy script.
On this page:
|Table of Contents|
The value of the calculated field
textutils is a utility object of class TextUtils providing useful methods to manipulate text and HTML
A NumberTool instance that can be used to format number values.
The value is formatted to
To add an IMG tag to display an icon to the left of the number:
"<img src='/images/icons/priority_trivial.gif'> "+numberTool.format(value);
textutils variable is a utility object of class TextUtils providing useful methods to manipulate text and HTML.
textutils.noNull(issue.get("description")) + issue.key returns a text avoiding null in case there is no Description of the issue.
log variable is a
Logger instance that is used to output information like errors and warnings into the atlassian-jira.log file located in your Jira home directory. You can also use the
log variable to output data to the script tester result panel during script development and debugging. There are five logging levels available in
log4j, and they are all output to the script tester result panel. However, by default, only WARN and ERROR level logs are output to the atlassian-jira.log file, so you should only use
log.error(...) for run-time logging (as opposed to development-time logging). To see other levels in atlassian-jira.log, you can raise the logging level for the com.innovalog package.
In addition to the above variables, you can also define your own variables in the Groovy script.
For example, Condition to check whether the Fix Version/s has a particular version.
Search for issues using JQL
Global function to get a Component/Service from Jira or any loaded add-on
jqlSearch("<JQL expression>", <maxResults>)
jqlSearch("<JQL expression>", <maxResults>)is a simple function that you can use to search for issues using a JQL. The function expects the following:
JQL expression: A JQL query
maxResults: maximum number of issues to return
Example: Calculate the Story points of all issues of a specific project and display them on the current issue as Total Story points.
workdaysBetween(<Date from>, <Date to>) is a global function that returns aLongrepresenting the number of work days (excluding Saturdays and Sundays) between two Dateobjects. It returns
nullif one of the two parameters is
null. For example:
Code Block language groovy
returns the number of days between the issue creation and the due date
Code Block language groovy
workdaysBetween(issue.created, new Date())
returns the number of days from the issue creation to now.
Note that the current user will be restored when the code block is exited.
getOrganization is a global function that returns a Jira Service Management Organization from its name or ID.
returns the Organization named “Appfire”.
return the Organization with ID 5.
returns the users that belong to the Appfire organization.