Integrating with Portfolio for Jira's Public Java API

While writing a plugin for Jira Server can be understandably daunting at first, writing a plugin for a plugin like Portfolio may just feel like a step too far. But once you know a few tricks, you'll find out soon enough that there's really not much to it.

In this walkthrough, we're going to show you how you can write a Jira plugin that integrates with the recently announced Portfolio for Jira Java API. With this demo, it will take less than 15 minutes -- to get from nothing to working.

Before you begin, make sure you have a copy of the latest Portfolio Server OBR from Marketplace, and you've locally installed the latest Atlassian SDK.

We're going to create a new plugin for Jira by running this command in a terminal:

$ atlas-create-jira-plugin

Put something sensible for group and artifact id, or use these values:

Define value for groupId: : com.atlassian.jpos.demo
Define value for artifactId: : api-demo
Define value for version: 1.0.0-SNAPSHOT: :
Define value for package: com.atlassian.jpos.demo: :

Let's fix up our dependencies in the root pom.xml file. We want to upgrade a few things, so let's update the section at the bottom to look like this:

  <!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
  <!-- TestKit version 6.x for JIRA 6.x -->

Notice that we've upgraded Jira and Spring Scanner, and have added a JPOS target.

Now let's import the additional dependencies we want to use in our plugin:

<!-- Portfolio Public API -->

<!-- Spring annotations -->

To complete the spring scanner upgrade:

  • Change the <scope> of atlassian-spring-scanner-annotation to be provided, and not compile.
  • Remove the atlassian-spring-scanner-runtime dependency.
  • Remove the springframework and blueprint imports from the <Import-Package>*</Import-Package> block. In the sample below, you'll need to remove org.springframework.osgi.*;resolution:="optional", and org.eclipse.gemini.blueprint.*;resolution:="optional",

Since our plugin needs Portfolio, and Portfolio needs Jira and Jira Software, let's add the necessary applications inside the maven-jira-plugin <configuration> block:


To make startup a bit more stable, we also added some magic sauce to the <configuration> block:

<jvmArgs>-Datlassian.plugins.enable.wait=300 -Dcom.atlassian.jira.startup.LauncherContextListener.SYNCHRONOUS=true -Xmx2048m -Xms512m</jvmArgs>

Next, you'll need to create or overwrite the file src/main/resources/META-INF/spring/plugin-context.xml with:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

The only difference should be the /2 after all the atlassian-scanner URLs.

Now, we can create pages and menus per usual.

For example, let's create a page template at src/main/resources/html/success.vm:


    <title>Portfolio for Jira Public API Tests</title>
    <h1>Portfolio for Jira Public API Says: $result</h1>

You can then register your menu and web page in src/main/resources/atlassian-plugin.xml:

<web-section name="apiDemoSection" i18n-name-key="" key="demo-section" location="demo-item-link" weight="1000">
  <description key="api-demo.description">The demo-api plugin</description>
  <label key="demo-api.label"/>
  <link linkId="demo-api-link">/secure/DemoView.jspa</link>
<web-item name="apiDemoItem" i18n-name-key="" key="demo-item" section="" weight="1000">
  <description key="api-demo.description">The demo-api plugin</description>
  <label key="api-demo.label">demo</label>
  <link linkId="api-demo-link">/secure/DemoView.jspa</link>

<webwork1 key="api-demo-ww1" name="demo web actions" class="java.lang.Object">
    <action name="com.atlassian.jpos.demo.DemoView" alias="DemoView">
      <view name="success">/html/success.vm</view>

You can also configure some default translations in src/main/resources/

api-demo.label=JPOS API Demo
api-demo.description=A demo plugin that integrates with the JPOS Public API

Now, we can write a page view that calls the Portfolio API and renders the result to a page.

Create a new Java file at src/main/java/com/atlassian/jpos/demo/ with:

package com.atlassian.jpos.demo;

import com.atlassian.jira.web.action.JiraWebActionSupport;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.rm.portfolio.publicapi.interfaces.plan.PlanAPI;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.concurrent.atomic.AtomicLong;

public class DemoView extends JiraWebActionSupport {

  private final PlanAPI planApi;

  public DemoView(@ComponentImport PlanAPI planApi) {
    this.planApi = planApi;

  public String execute() throws Exception {
    return "success";

  public String getResult() {
    try {
      long numPlans = planApi.count();
      return numPlans + " Plan" + (numPlans == 1 ? "" : "s");
    } catch (Exception e) {
      return "error: " + e.getMessage();

You can now build and run your plugin:

$ atlas-run

(or use atlas-debug during active development).

This will build and package your plugin, start up a version of Jira with Jira Software, and install your plugin.

Unfortunately, Portfolio is not available as a public application, so your plugin will fail to start (OSGi can't find the PlanAPI!). However, Jira with Jira Software should start up fine.

We can fix this by logging in (username: admin, password: admin), going to the Add-ons section under the Administration menu, and manually uploading the Portfolio plugin on the Manage add-ons tab.

Add-ons menu Manage Upload
Add-ons menu Manage add-ons Upload add-on

ℹ️ TIP: You should only have to manually add the Portfolio plugin after running atlas-mvn clean.

Now, you'll need to re-enable your plugin. You'll see two greyed-out copies of api-demo: one is the plugin, and the other is a testing module.

You can go ahead and enable them both -- though for this walkthrough, you'll only need to enable the copy with com.atlassian.jpos.demo.api-demo add-on key. This will start up Portfolio.

Enable plugin

Navigate to the Jira dashboard, or refresh the page, and the JPOS API Demo menu should now appear in the header.

Click JPOS API Demo to access your new Public API page, which should show the result of calling the Portfolio API.


Success! Now go forth and plan ahead!

You can find all the code on bitbucket.

Reach out to us in the User or Developer Communities if you have any questions, or even to share any new integrations with Portfolio that you may know of.


The Portfolio for Jira Server Team