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

How do I set certain groups to a new JIRA project as part of a specific Project Role using JIRA API?

I'm using JIRA 8.0.3. We had a need to programmatically create JIRA projects from an existing template which would be triggered in a workflow transition as part of a new Issue Type. I was able to do this successfully by using the JIRA API from a post-function inline script (ScriptRunner).

As a next step, I need to add groups to specific Project Roles for the newly created JIRA project. Please bear in mind that the groups would be unique for each new JIRA project. I did look into JIRA API about ProjectRole, ProjectRoleManager and ProjectRoleService. However, the method addActorsToProjectRole expects a Collection of Actors. In my case, the group name to add would be a String. So I'm not sure how to proceed.

Here is my existing code (projKey, projName, projLead are user-entered information; origUser is the user who is person clicking on the workflow transition to create the project) -

Builder builder = new Builder()
builder.withKey(projKey.toString()).withName(projName.toString()).withLead(projLead)
def data = builder.build()
// Validate whether logged in origUser  has privileges to create the project from existing Project Template

def projectResult = projectService.validateCreateProjectBasedOnExistingProject(origUser, PROJECT_TEMPLATE_PID, data)

Project prj = projectService.createProject(projectResult)

The above snippet works for creating a new project with the existing project template id.

However, I'm stuck now trying to add groups to the project for specific project roles. I have looked at the below documentation but can only find addActorsToProjectRole (as mentioned above) and nothing related to adding users or groups to a project role for a project.

https://docs.atlassian.com/software/jira/docs/api/8.0.3/com/atlassian/jira/bc/projectroles/ProjectRoleService.html

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

375 views 1 3
Join discussion

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