Create new key while create project by API

Binu George January 14, 2016

HI All,

          How will get all project keys. Because while we create new project by API  i need to give different key. So before that i need to check all existing Key and create new Key. How will achieve this?

2 answers

1 vote
Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 14, 2016

Since you have a collection on project keys for each project you have to do a loop over all projects. Here is a code example how to get all project keys:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager

ProjectManager projectManager = ComponentAccessor.getProjectManager();

List<String> prjKeys = new ArrayList<>();

for(Project project: projectManager.getProjectObjects()){
    prjKeys.addAll(projectManager.getAllProjectKeys(project.getId()))
}

return prjKeys.toString()
0 votes
Piyush_Annadate February 14, 2017

can you please share your code.. I'm also working on something related to this

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events