Web Resources

Available:

Bamboo 2.3 and later

On this page:

Description

Bamboo plugins may define downloadable resources. If your plugin requires Bamboo to include additional static Javascript or CSS files, you will need to use downloadable web resources to make them available. Web resources are included for download, at the top of the page in the header. Web resources can also take advantage of caching (i.e. only download a resource if it has changed) and batching (i.e. serve multiple files in one request). If you would like to include other static files for download, such as images, please see Downloadable Plugin Resources.

Defining a Single Web Resource

Downloadable resources are configured to map a name of some downloadable file to its location within the plugin jar-file.

<web-resource key="autofavourite-resources" name="Auto-Favourite Resources">
    <resource type="download" name="autofavourite.css" location="autofavourite.css"/>
  </web-resource>
  • Resources must be contained within a <webresource> tag.
  • The key of the webresource is how it will be referenced from within the application
  • Each resource must be of type="download"
  • The name of the resource will be suffixed to the URL
  • The location of the resource is where it appears within the plugin itself

Referring to Web Resources

In Freemarker or your plugin's Action, you need to refer to a WebResourceManager, and call the requireResource() method. Getting a reference to a WebResourceManager is application specific, but in Bamboo it would be:

${webResourceManager.requireResource("com.atlassian.bamboo.plugin.autofavourite:autofavourite-resources")}   

The URL for a downloadable resource is application specific. For Bamboo it would be follows:

{server root}/s/{build num}/{plugin version}/{system counter}/c/download/resources/{plugin key}:{module key}/{resource name}

For the above example:

<link type="text/css" rel="stylesheet" href="http://bamboo.example.com/s/170/1.0/1/_/download/resources/com.atlassian.bamboo.plugin.autofavourite:autofavourite-resources/autofavourite.css">

will be inserted in the header of the page.

Was this page helpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport