I have button "Review" in Jira workflow with no screens. Whenever a manager reviews the issue he has to click on the Review button. Once this button is clicked jython script should automatically create comment like "Review performed by <user who clicked review> at <current time>.
I have written a jython script in post function however it does not work and give me errors. Below are the script and errors. Let me know where it went wrong and provide the correct syntax pls.
from com.atlassian.jira import ComponentAccessor
from com.atlassian.jira import ComponentManager
from com.atlassian.jira.util import ImportUtils
from com.atlassian.jira.issue.comments import CommentManager
from com.atlassian.jira.datetime import datetime
subTaskManager = ComponentManager.getInstance().getSubTaskManager()
commentManager = ComponentManager.getInstance().getCommentManager()
authenticationContext = ComponentManager.getInstance().getJiraAuthenticationContext()
currenttime = datetime.now()
comment = "Peer review performed by \"" + authenticationContext.getLoggedInUser().toString() + "\" at \"" + currenttime
root cause: Traceback (most recent call last): File "<string>", line 5, in <module> ImportError: cannot import name datetime
Try this one. Dont use componentmanager most of functions were deprecated.
from com.atlassian.jira.component import ComponentAccessor from com.atlassian.jira.issue import Issue from java.util import Calendar ComponentAccessor=ComponentAccessor() JiraAuthenticationContext=ComponentAccessor.getJiraAuthenticationContext() LoggedUser=JiraAuthenticationContext.getUser() Calendar = Calendar.getInstance(); Time=Calendar.getTime().toString() comment = "Peer review performed by \"" + LoggedUser.toString() + "\" at \"" + Time CommentManager=ComponentAccessor.getCommentManager() CommentManager.create(issue, LoggedUser, comment, True)
Atlassian Summit is an excellent opportunity for in-person support, training, and networking.Learn more
...there's anything I've learnt from working, it's that people are lazy! No offense to anyone reading this, but it's true and we can all admit it. The easier you make something for someone, the more...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs