jira 7 and javascript for web-item

Brian Chabot November 20, 2017

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 votes
miikhy
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.
November 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!

Brian Chabot November 30, 2017

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.

miikhy
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.
November 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!

Brian Chabot November 30, 2017

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.

miikhy
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.
November 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