So far as have seen that we can add web items to new or existion web sections, and use conditions to determine whether they should be displayed for the current user, or issue, page etc.

However, if you want to dynamically generate web items according to the current circumstances, you need a web item provider. Official documentation is lacking, vote for PLUGFRAG-17.

Examples of a web item provider might be:

These examples are for JIRA, but something similar should work for Bitbucket. Confluence does not support these at the time of writing.


First of all, let’s look at a simple example. For the web item provider, you must either provider a class that implements com.atlassian.plugin.web.api.provider.WebItemProvider, or, more simply, a script that returns a collection of com.atlassian.plugin.web.api.WebItem. Using a com.atlassian.plugin.web.api.model.WebFragmentBuilder is the easiest way to create a collection of WebItem.

Set up the fragment like in the following screen capture:

item provider simple

The provider class/script can either under a script root, or inline. Here is a simple example:

import com.atlassian.plugin.web.api.model.WebFragmentBuilder

["Foo", "Bar", "Quz"].collect {
    new WebFragmentBuilder(50). (1)
        id("sample-web-item-${it.toLowerCase()}"). (2)
        label("$it Sample Web Item").
        title("$it Sample Web Item Title").
        addParam("data-my-key", "data-value"). (3)
        addParam("iconUrl", "/jira/images/icons/priorities/highest.svg"). // not all places will show icons
        webItem(""). (4)
1 The 50 refers to the weight of the item
2 Give each web item a unique ID
3 Additional data element items
4 This parameter refers to the section, but it’s defined by the section for the context provider itself
There are a couple of shortcuts in this script that can be confusing. No return statements are used (as the result of the last statement is returned in groovy). So the collect returns the web items.

Have questions? Visit the Atlassian Community to connect, share, and learn with other Atlassian users and experts, including Adaptavist staff.

Ask a question about ScriptRunner for JIRA, Bitbucket Server, or Confluence.

Want to learn more? Check out courses on Adaptavist Learn, an online platform to onboard and train new users for Atlassian solutions.