This Tutorial introduces and familiarizes JMCF customers with writing Groovy scripts in the field configurations of some custom fields provided by JMCF to enhance the potential of the custom field value calculation. To write a Groovy script in JMCF you do not need to be proficient in the language, but a basic understanding of some simple and important concepts of the language is required. This tutorial teaches writing simple Groovy scripts that will get you started quickly and will give you more insight into Groovy and its use in JMCF. However, this is not a complete reference for the Groovy language. To acquire in-depth knowledge about it refer to the official documentation for Groovy that has plenty of tutorials and excellent documentation both for beginners and advanced users of the language.
Before you begin:
- You need to install the JMCF add-on in your Jira Server instance
- Some hands-on experience in Java or any other OOP language is helpful
By the end of this tutorial, you will be able to write simple Groovy scripts in JMCF.
Introduction to Groovy
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 is easy to learn, has smooth Java integration, vibrant and rich ecosystem and powerful features. It brings the attractive benefits of dynamic languages to a robust and well-supported platform.
- Seamless integration with Java - Groovy is friendly with the Java Runtime Environment and its syntax is aligned with Java
- Feature-rich language - Groovy has three main enhancements over and above those of Java: language features, libraries specific to Groovy, and additions to the existing Java standard classes (known as the Groovy Development Kit, or GDK)
Using IDE: You can use any IDE like IntelliJ IDEA or Eclipse or NetBeans to write your Groovy scripts and then copy them into JMCF custom field configurations.
Using the Groovy editor: The JMCF add-on provides an integrated editor and tester that lets you write and test script. To write your script in the custom field configuration:
- Log in to your JIRA Server instance as an administrator.
- Go to the Administration icon and click on it.
- Click on
Issues - > Custom fields.
- Locate the custom field on the Custom Fields administration page.
- Click on the cog wheel and click on
- Click on
Edit Groovy Formula/Edit Format Expression, whichever is applicable
The Groovy editor is displayed. You can write your script and test it against an issue. The Groovy editor in JMCF has:
- On-the-fly syntax checking - to provide information about syntax errors in your script
- Automatic indentation of the code - for easy understanding of the code
- An online help system that helps you write Groovy code quickly
See here for more information on the Groovy editor and tester.
To start learning about the Groovy language, click here. If you are already familiar with the Groovy language but would like to learn more about how to use it in JMCF, click here.