The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira Portfolio JAVA API create plan

Şafak Şahin
August 13, 2018

Hi,
We are trying to create a portfolio plan from your portfolio java API.
But we can't figure it out to how to set a filter and set the other steps also.

Can you share us an example code piece or show how to fix below code?

Here is our groovy code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.version.*
import com.atlassian.plugin.PluginAccessor

MutableIssue issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("DPMO-2637")
Collection<Project> projectList = new ArrayList<>()
projectList.add(issue?.getProjectObject())
List<Version> versionList = ComponentAccessor.getVersionManager().getAllVersionsForProjects(projectList, true).toList()
Set<Long> unarchivedVersionList = versionList.findAll

{it.archived}

.collect

{it.id}

.toSet()

PluginAccessor pluginAccessor = ComponentAccessor.getPluginAccessor()
Class planDTOClass = pluginAccessor.getClassLoader().findClass("com.atlassian.rm.portfolio.publicapi.interfaces.plan.PlanDTO")

def planDTO = ComponentAccessor.getOSGiComponentInstanceOfType(planDTOClass)
def planDTOBuilder = planDTOClass.builder()

planDTO = planDTOBuilder.withTitle(issue.key.join("-",issue.summary))
.withExcludedVersions(unarchivedVersionList).build()
log.warn(planDTO.id)

 

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Şafak Şahin
August 16, 2018

Hi,

Plan API is read-only.

At the moment we just can't use it for create portfolio plan.

0 votes
Pradeep Kattimani
July 20, 2021

Hi, 

Can anyone please give the details regarding how to creating the portfolio plan using scrptrunner?