Versions Compared

Key

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


Section


Column

Starting with version 2.0.0, the JMCF add-on comes with a Groovy script editor and tester in the configuration screens of the calculated custom field. This document details the Groovy script tester, its availability and features.

The Groovy script tester tool lets you test your written script against any issue. The main advantage of this tool is that you can quickly test and debug your script and make changes without having to actually save the custom field and recalculate the calculated field value.


Column
width50%


Panel
borderColorsilver
bgColor#f5f5f5
borderWidth1
borderStylesolid

On this page:

Table of Contents



...

Panel

Test a script that returns the sum of two number fields:

  1. Locate the custom field on the Custom Fields administration page.
  2. Click on the cog wheel and click on Configure.
  3. In the Groovy editor, write the following lines of code:

    Code Block
    languagegroovy
    linenumberstrue
    issue.get("customfield_10114") + issue.get("customfield_10150")


  4. Click on the Test Groovy Script button on the toolbar.
  5. Type an Issue key.
  6. Click on Test.
  7. The following result is displayed:

...

  • Identify the problem, from the Message that displayed a null pointer exception error and the Stack that displayed the line number on which the error occurred.
  • Correct the problem, checking for null values and then returning the result.

  1. In the Groovy editor, write the following lines of code:

    Code Block
    languagegroovy
    linenumberstrue
    if (issue.get("customfield_10028") == null || issue.get("customfield_10006") == null)
        return null;
    else  
    return issue.get("customfield_10028") + issue.get("customfield_10006");


  2. Click on Test again.
  3. The following result is displayed:

...