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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get commentManager in JIRA 8 velocity files

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

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 !

  • 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

Hi Gaël,


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

Thanks

juergen 

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
DEPLOYMENT TYPE
SERVER
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across Jira Cloud instance.   📢 Get y...

122 views 6 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you