Cloud Migration Resources
Planning a Jira Cloud migration? These resources can help you get started:
→ JMWE Cloud features – Review Cloud features and understand key differences between DC and Cloud.
→ Migration support from Appfire – Learn how we can help you migrate smoothly.
Writing your first Groovy script
This tutorial will guide you through writing your first Groovy script.
Let us write a simple Groovy script for the functional use case: Store the author who approved an issue into a User picker custom field
You can do this by adding the Set field value post-function to the transition that should be triggered to approve the ticket, write a Groovy script in the post-function configuration to return an ApplicationUser object representing the logged in user and then set the value of the User picker custom field to the result of the written Groovy script.
You need not create a user picker field or configure a post-function for this. The imported backup has everything in place.
Writing the script
Step 1 - Navigate to the post-function
Go to the Administration icon and click on it.
Go to Issues - > Workflows
Locate the workflow GIJ: Task Management Workflow
Edit it
Click on transition Approve
Go to the
Post-functionstabEdit the
Set field valuepost-function which is the first post-function in the list.
Step 2 - Write the script in the post-function
Write the following script in
ValuecurrentUserLine 1 : Using the currentUser variable that holds an ApplicationUser representing the current user (i.e. the user triggering the transition) in the Groovy context.
Your post-function should look like this:
Step 3 - Test your script
Click on
Test Groovy Script.Input the issue key
GIJ-1Click on
TestThe following result will be displayed.
Step 4 - Save the configuration
Click on
UpdatePublish the workflow (you don't need to save a backup copy)
Step 5 - Test it on an issue
Go to the issue
GIJ-1Click on the transition
Approve.Verify that the
Author who approvedfield underPeoplegets updated withJohn Carter.
Use cases
You can use this script in any other relevant context, such as
Assigning the issue to the current user
Adding the current user to the Request Participants of the issue