How do you create a scrum Board using the Java api?

I am using the Jira SDK to create a plugin which will automate the process of creating my default project setup. A part of this default setup includes a scrum board. I've been unable to find any examples of creating a scrum board through the SDK, so I've been trying to figure out the process by piecing together the relevant classes.

I've been trying stuff like this:

// createBoard creates a new scrum board for a project
static String createBoard(ApplicationUser user, String projectKey)
{
try
{
// get Jira Components
ProjectManager projectManager = ComponentAccessor.getProjectManager();
BoardService boardService = ComponentAccessor.getComponent(BoardService.class);
SearchRequestService searchRequestService = ComponentAccessor.getComponent(SearchRequestService.class);
JiraServiceContext ctx = new JiraServiceContextImpl(user);
// get the project the board is for
Project project = projectManager.getProjectObjByKey(projectKey);
// build a search request
JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();
builder.where().project(project.getName());
Query query = builder.buildQuery();
SearchRequest searchRequest = new SearchRequest(query);
// set the name of the filter
searchRequest.setName("Filter for " + project.getName());
// set the permission of the filter
SharePermission permission = new SharePermissionImpl(ShareType.Name.GLOBAL,"","");
Set<SharePermission> permissions = new HashSet<>();
permissions.add(permission);
SharePermissions sharePermissions = new SharePermissions(permissions);
searchRequest.setPermissions(sharePermissions);
// set the owner of the filter
searchRequest.setOwner(user);
// create the filter
SearchRequest newSearchRequest = searchRequestService.createFilter(ctx,searchRequest,true);
Long filterId = newSearchRequest.getId();
// construct Board jql
String jql = "project = AAP AND name = Board AND type = scrum AND filterId = " + filterId;
// create Board object
BoardCreationData data = new BoardCreationData.Builder().projectId(project.getId()).jql(jql).build();
ServiceOutcome<Board> outcome = boardService.createBoard(user,data);
// if successful, return no error messages
return null;
}
catch (Exception e)
{
// return any error messages
return e.getMessage();
}
}

So far, I have not been able to create scrum board.

It seems like the classes and functions are there, it should be possible to create a scrum board in this way. But so far, I haven't been able to, and I haven't found any examples showing how to.

 

2 answers

Have you made any progress on this, Kirk?  I am attempting to do something very similar and, though I see no errors generated during the Board creation, I don't see that the Board exists anywhere.

Sorry to say, I have not made it any further than generating the invisible Board object. I have searched for assistance in several ways, and though this question did not get any reply, what I am typically told is to use a third party program. These programs are not free, and they are also Jira plugins. So there is some way to do it, but I have not figured it out.

 

In case you might want to know, here is one of those third party programs: https://marketplace.atlassian.com/plugins/org.swift.jira.cli/cloud/overview

0 vote

 Hi,

 

As discussed internally with an app developer, here's my answer for board retrieval. Hope this helps those in need of this info:

 

1. On your first creation of your plugin, make sure that Jira Software OBR is installed so you have all the software maven dependencies available to you
# In your {{pom.xml}} add the greenhopper as such:

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

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.anne</groupId>
<artifactId>AnneJiraPlugin</artifactId>
<version>1.0.0-SNAPSHOT</version>

<organization>
<name>Example Company</name>
<url>http://www.example.com/</url>
</organization>

<name>AnneJiraPlugin</name>
<description>This is the com.anne:AnneJiraPlugin plugin for Atlassian JIRA.</description>
<packaging>atlassian-plugin</packaging>

<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
<!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
<!--
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-annotation</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-runtime</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>

<!-- WIRED TEST RUNNER DEPENDENCIES -->
<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
<version>${plugin.testrunner.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2-atlassian-1</version>
</dependency>

<!-- Uncomment to use TestKit in your project. Details at https://bitbucket.org/atlassian/jira-testkit -->
<!-- You can read more about TestKit at https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Smarter+integration+testing+with+TestKit -->
<!--
<dependency>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-client</artifactId>
<version>${testkit.version}</version>
<scope>test</scope>
</dependency>
-->

<dependency>
<groupId>com.atlassian.jira.plugins</groupId>
<artifactId>jira-greenhopper-plugin</artifactId>
<version>6.7.7</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<!-- Uncomment to install TestKit backdoor in JIRA. -->
<!--
<pluginArtifacts>
<pluginArtifact>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-plugin</artifactId>
<version>${testkit.version}</version>
</pluginArtifact>
</pluginArtifacts>
-->
<enableQuickReload>true</enableQuickReload>
<enableFastdev>false</enableFastdev>

<!-- See here for an explanation of default instructions: -->
<!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>

<!-- Add package to export here -->
<Export-Package>
com.anne.api,
</Export-Package>

<!-- Add package import here -->
<Import-Package>
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
com.atlassian.jira.plugins.*,
com.atlassian.greenhopper.*,
*
</Import-Package>

<!-- Ensure plugin is spring powered -->
<Spring-Context>*</Spring-Context>
</instructions>
</configuration>
</plugin>

<plugin>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<executions>
<execution>
<goals>
<goal>atlassian-spring-scanner</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<scannedDependencies>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
</dependency>
</scannedDependencies>
<verbose>false</verbose>
</configuration>
</plugin>
</plugins>
</build>

<properties>
<jira.version>7.5.0</jira.version>
<amps.version>6.3.6</amps.version>
<plugin.testrunner.version>1.2.3</plugin.testrunner.version>
<atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
<!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
<!-- TestKit version 6.x for JIRA 6.x -->
<testkit.version>6.3.11</testkit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>

 

2. I tested my retrieval by creating a private REST endpoint, this is what my board retrieval looks like:


package com.anne.rest;

import com.atlassian.greenhopper.model.rapid.RapidView;
import com.atlassian.greenhopper.service.ServiceOutcome;
import com.atlassian.greenhopper.service.rapid.view.RapidViewService;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.security.JiraAuthenticationContext;
import com.atlassian.jira.user.ApplicationUser;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Path("/board-anne")
public class BoardRest{

private JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
private RapidViewService rapidViewService = (RapidViewService) ComponentAccessor.getOSGiComponentInstanceOfType(RapidViewService.class);


@GET
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response getBoard() {
ApplicationUser user = jiraAuthenticationContext.getLoggedInUser();

ServiceOutcome<RapidView> rapidView = rapidViewService.getRapidView(user, Long.valueOf(1));

System.out.print(rapidView.getValue().getName());

return Response.ok(rapidView.getValue().getName()).build();
}
}
```
- This should return the Kanban Name (see screenshot)

 

3. atlassian-plugin.xml looks like this:

<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}" />
<param name="plugin-icon">images/pluginIcon.png</param>
<param name="plugin-logo">images/pluginLogo.png</param>
</plugin-info>

<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="AnneJiraPlugin"/>

<!-- add our web resources -->
<web-resource key="AnneJiraPlugin-resources" name="AnneJiraPlugin Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>

<resource type="download" name="AnneJiraPlugin.css" location="/css/AnneJiraPlugin.css"/>
<resource type="download" name="AnneJiraPlugin.js" location="/js/AnneJiraPlugin.js"/>
<resource type="download" name="images/" location="/images"/>

<context>AnneJiraPlugin</context>
</web-resource>

<rest name="My Rest Resource" key="my-rest-resource" path="/anne" version="1.0">
<description>The My Rest Resource Plugin</description>
</rest>

</atlassian-plugin>

 

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 Jun 14, 2018 in Jira Service Desk

How the Telegram Integration for Jira helps Sergey's team take their support efficiency to the bank

...+ reading Fantasy). The same is true for him at the bank he works for: Efficiency is key when time literally equals money. Read on to learn how Sergey makes most of the time he has by...

419 views 2 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