Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Groovy is an object-oriented programming language for the Java platform. It is a dynamic language with features similar to those of Python, Ruby, Perl, and Smalltalk. It , and can be used as a scripting language for the Java Platform. It is easy to learn, has smooth Java integration, a vibrant and rich ecosystem, and powerful features. To know learn more about Groovy, see the official Groovy Documentation.
Info |
---|
Please note: JMWE for Jira Server currently supports Groovy 3 |
Learning Groovy
To learn more about the Groovy language:
Start with our Groovy tutorial: Groovy tutorial
Introduction to Groovy: See Learn Groovy in Y minutes and Learn Groovy in one Video
Tutorials - many tutorials are available online, such as TutorialsPoint and The Groovy 2 Tutorial (this is on an older version of Groovy, but still contains much useful information).
References - See The Apache Groovy programming language and The Complete Apache Groovy Developer Course (paid option)
Groovy in JMWE
Groovy in JMWE can be used either to write a Groovy expression or a Groovy template in the various workflow extension configuration . options; Groovy expression results in JMWE are used in various JMWE Conditions, Validators, and Post-functions, including:
Conditions:
The Target issues section of Related Issues Condition and Related Issues Status Condition, when Issues issues returned by a Groovy script (or Issues returned by a JQL search is ) are selected under the Which Issues field.
Condition Conditions on the related issues section of Related Issues Condition and Related Issues Status ConditionScripted (Groovy) Condition to execute a condition.
The Build-your-own Condition to execute a condition configured entirely using Groovy.
Validators:
The Target issues section of Related Issues Validator and Related Issues Status Validator, when Issues issues returned by a Groovy script (or Issues returned by a JQL search is ) are selected under the Which Issues field.
Condition Conditions on the related issues section of Related Issues Validator and Related Issues Status ValidatorScripted (Groovy) .
The Build-your-own Validator to execute a validator configured entirely using Groovy.
Conditional execution /validation using a Groovy expression in all the validators
Post-functions:
The Target issues section of all post-functions that operate on related issues, when Issues issues returned by a Groovy script (or Issues returned by a JQL search is ) are selected under the Which Issues field.
All post-functions with , using the Conditional execution/validation using a Groovy expression section section to execute a post-function conditionally.
The Comment issue and Comment related issues post-functions post-function to create the body of the comment by selecting Groovy expression as ; select Groovy expression as the Comment type.
Create/Clone issue(s) post post-function to
Calculate a project by selecting Calculated in Projectselecting Calculated in Project
Calculate a parent issue key by selecting Calculated in Parent selecting Calculated in Parent issue
Set fields of new issue by selecting Groovy expression as the Value type and selecting Groovy expression as the Value type
Add a comment to the current issue by selecting Groovy expression as the Comment selecting Groovy expression as the Comment type
Multiple iterator section of the Create/Clone issue post-function
Display message to user post-function to input:
The Message title
The Message body
The Action type
Email Issue post post-function to:
Write the Subject, HTML body, Text body
Attachments returned by a Groovy script
Set the Recipients from the Recipients for the scriptemail
Set other email addresses from the script
Exclude users
Link issues to the current issue in:
JQL expression
Filter expression
Scripted (Groovy) operation on issue post-function to execute a Groovy script against an issue
Set field value and Set field value of linked issues issue fields post-functions to set a field value by selecting Groovy expression as the Value the Value type
Transition current issue, Transition linked issues and Transition related issues issue(s) post-functions in:
Calculated transitions
Add field in transition screen with the result of a Groovy script
Unlink issues from the current issue post post-function to unlink issues based on the result of a Groovy condition
Groovy Console of the JMWE Administration section to test/run Groovy scripts
Shared Groovy Scripts under JMWE administration
Transitions activity tab on issue view page, to show the Transitions activity tab on the issue view screen based on a Groovy condition
Writing Groovy scripts in JMWE
To learn how to write groovy scripts for JMWE, see:
Groovy editor - This document explains you the Groovy editor in JMWE where you can write your Groovy script or Groovy template.
Variables and functions used in a Groovy expression - This document explains you the variables available for your Groovy scripts and how to create new variables in your Groovy scripts.
API Interfaces - The document details the API interfaces
Accessing the fields of an issue - This document explains you on how to access the fields of an issue.
Expected value for each field type when the value type is a Groovy expression - This document lists the expected values for each field type of your issue.
Groovy templates - This document explains you on how to write Groovy templates in the Groovy editor
Groovy script tester - This document explains the Groovy script tester which helps you test your written script or template and debug it.
Using Groovy Grapes
JMWE for Jira Server/ Data Center now supports Groovy Grapes for dependency management and to import external libraries into Groovy scripts within JMWE. You can now add maven repository dependencies (and other repositories) to your classpath. See http://docs.groovy-lang.org/latest/html/documentation/grape.html for more information.
As an example, the following script grabs the OpenCSV library from Maven Repository:
Code Block | ||
---|---|---|
| ||
@GrabResolver(name='opencsv', root='https://mvnrepository.com') @Grab(group = 'com.opencsv', module = 'opencsv', version = '4.2') class Example { Object getExternalLibrary() { return Class.forName('com.opencsv.bean.CsvToBeanBuilder').getDeclaredMethods()*.name } } new Example().getExternalLibrary() |
You are viewing the documentation for Jira
Data Center.
On this page:
|
---|