Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,219
Community Members
 
Community Events
184
Community Groups

Automatically add a comment

I am using Groovy Scriptrunner. How can I add a comment that says, "In UAT" when a transition is completed for an issue?

2 answers

1 accepted

2 votes
Answer accepted
Aidan Derossett _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 25, 2017

Hey Karrie!

I've coded up a simple example for you to use here:

import com.atlassian.jira.component.ComponentAccessor

//Get appropriate managers/handlers
def commentManager = ComponentAccessor.getCommentManager()
def authContext = ComponentAccessor.getJiraAuthenticationContext()

//Define currentUser because it is not an available default
def currentUser = authContext.getLoggedInUser()

//Add comment to issue transitioned. The name on the comment will be the current user's name.
//The boolean value delegates whether or not an event is fired.
commentManager.create(issue, currentUser, "This is where the comment goes!", true)

Steps to use in transition:

  • Go to the workflow of the project that you would like this functionality to be present in.
  • Edit the workflow in Diagram view.
  • Click on the transition that you would like to add it to.
  • Choose Post-Function in the pop-up that appears to the right of the screen.
  • Choose to add a new Post-Function and then select "Script Post-Function" and hit "Add"
  • Then choose a "Custom Script Post-Function"
  • You then add the code, or something similar, in the Inline Script box (add a relivent note).
  • After you add the Post-Function, ensure that it is the very last script ran by pushing it down to the very bottom of the diolog box that reads "The following will be processed after the transition occurs."
  • You may then publish the workflow and you're good to go.

The script that I provided above is a very simple example, but you can add more complex properties to the comment or add make a default user to be the commenter if you like (etc...). You can see other possible methods to use in the JIRA API.

Thank you!! That worked perfectly!

Aidan Derossett _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 25, 2017

No problem, if you have any other questions let me know! :)

Do you know how to do this with Jira and scriptrunner cloud?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events