Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jira Portfolio JAVA API create plan Edited

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

0 votes
Answer accepted

Hi,

Plan API is read-only.

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

Hi, 

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

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you