jira 7 and javascript for web-item

I'm in the process of upgrading a custom plugin we created in order to move into jira 7. The plugin is currently in jira 6.4 and using some now deprecated code, example WebResourceManager.

My issue is I cannot see my custom javascript files in the plugin. I'm building a fresh plugin using the 6.2.14 SDK and jira 7.2. From my understanding this is setting up Spring Scanner and could require me to alter my jspa files and not use WebResourceManager, or even PageBuilderService. But I have researched many solutions and I cannot get the plugin to see or use the javascript files. I have a base plugin set up, similar to Jtricks, but using a top.navigation.bar:

http://www.j-tricks.com/tutorials/use-of-decorators-on-jira-pages

I'm asking for a true, best practice solution for bringing in javascript files to use within a plugin. An example would be amazing as I'm running into issues with my attempts.

Thank you

1 answer

0 vote
Micky Caritte Community Champion Nov 29, 2017

Hi Brian,

The whole web resources management process is detailed in the documentation here: https://developer.atlassian.com/jiradev/jira-platform/building-jira-add-ons/jira-plugins2-overview/jira-plugin-module-types/web-resource-plugin-module

If your resources needs to be loaded from a velocity template, the webresourcesmanager seems to be the currently recommended solution. From within a servlet you might want to use PageBuilderService as explained in the above mentioned page.

I also advise you to set a specific context for your resources to avoid loading resources which are not needed in certain modules!

Hope this helps!

Micky,

Thank you for the assistance. I found a reference that used the PageBuilderService.assembler().resources().requireWebResource().

I have the basics running now. I really think the issue was running multiple javascript files. The original code had web-resources with dependencies to other web-resources. (JS files referencing other JS files basically). Jira did not like it for some reason. I'm going to review it later and see if I can refine them. Currently I have multiple web-resources, all with one JS file each, pointing to the same context. It's not perfect, but running now.

Micky Caritte Community Champion Nov 30, 2017

Great! Glad you found it out!

You should write your question as answered to help people inthe same situation heading to your answer :)

Have a great day and good luck for your plugin!

Micky - great point.

 

I found this:

https://comsysto.github.io/kitchen-duty-plugin-for-atlassian-jira/tutorial/01-introduction/

The tutorial focuses on Jira 7. This is a basic, but great tutorial that walks through Webwork, REST, and JS files, something we all need these days. It even goes through some basic testing setups.

I was able to create a web-item that lives in the system.top.navigation.bar section, and references the webwork that contains the actions for the input and post velocity pages. Finally I have the web-resource holding the JS file and it launches with the correct pages.

I think the biggest issue was understanding the web-resources and how they work together. I still need to set up dependencies to clean up the code a bit, but I'm getting there.

Micky Caritte Community Champion Nov 30, 2017

Good! This tutorial was really helpful for me as well as it's detailing many aspects of plugins concept (Active Objects, REST APIs...). The explanations are clear and well done, definitely a good start!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

46 views 0 4
Read article

Atlassian User Groups

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!

Find my local user group

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

Groups near you