How to get commentManager in JIRA 8 velocity files

Gaël NEUEZ January 25, 2021

Hello

I'm currently validating my upgrade from JIRA7 to JIRA8. Amongst my custom scripts, we had changed the email velocity files to include on 'comment added' event the history of (up to) 3 last comments. This was to help having a context.

The way I retrieved the comments was by getting the commentManager as follow:

#set ($componentAccessor = $constantsManager.getClass().forName('com.atlassian.jira.component.ComponentAccessor').newInstance())
#set ($commentManager = $componentAccessor.getCommentManager() )

 

However, now due to restrictions in security in JIRA8, it seems I ca no longer use the getClass method, hence this gives an error.

How can I get this manager now ?

Regards

 

3 answers

0 votes
IT Support October 6, 2021

Hi Gaël,

we were facing the similar issue after our Jira upgrade into version 8.x.
There is related question for NumberTool (https://community.developer.atlassian.com/t/velocity-numbertool-use/40801), from where you can implement required adjustments.

Therefore your script code snippet within velocity template file should be updated into:
#set ($componentAccessor = $ctx.get("jirautils").loadComponent("com.atlassian.jira.component.ComponentAccessor", $ctx.getClass()))
#set ($commentManager = $componentAccessor.getCommentManager() )

Please try and mark this answer as accepted/solved, if it works for you.
Have a good day !

0 votes
Kevin Dalton August 20, 2021
  • We were using this to pull watchers into emails and found the following workaround.

    • Created new customfield to store the values of watchers
    • Created new listener to update the field on any edit
    • Created new template for watchers
    • Update all fields to reference new VM file
0 votes
Juergen Lanner May 11, 2021

Hi Gaël,


could you figure out how to overcome this issue?
We just saw the same in our instance after upgrading.

Thanks

juergen 

Gaël NEUEZ May 11, 2021

Hi Juergen,

unfortunately I haven't been able to fix this issue, despite searching and scratching all of jira velocity doc and related articles...

So I had to give up this piece of functionality and return to normal old script.

If you ever find a way to get it working, I'm eager to know ;)

Regards

Gael

Suggest an answer

Log in or Sign up to answer