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.