Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

JMCF provides a suite of custom fields for use in your JIRA instance, of which some calculated custom field types use a formula written in the Groovy language to calculate/format the field value, such as:

  • Calculate and display the author of the last comment on the issue
  • Calculate and display the time spent in the current status
  • Calculate and display the user has last modified a field value

Writing a Groovy formula in JMCF

A Groovy editor is provided in all the applicable custom field configuration screens to write your Groovy formulae. You can either write them directly in the built-in editor, or use any IDE and then copy them to the editor. The built-in editor automatically indents your code, checks for syntax errors, colorizes keywords, comments, variables, and so on. JMCF includes a Groovy script tester tool that lets you test your formula against any issue. This allows you to debug your script and make changes without having to actually save the configuration, refresh the issue or perform a re-index and look at the field value on the Issue view screen to see the outcome.

Writing a Groovy formula: In the custom field configuration screen of calculated custom fields that use Groovy formula, click on Edit Groovy expression or Edit Format expression, whichever is applicable. For example to write a script to access the key of an issue:

Code Block
languagegroovy
issue.key

Testing the Groovy script: After writing the Groovy script, click on Test Groovy ScriptA modal dialog window opens, asking you to pick an issue to run the Groovy script against. Select an issue key. Click on TestThe result of the script is displayed.