Atlassian Development : Sample code to get the list of projects from your JIRA instance

Author

In this blog post, I will be sharing tips on how to populate a list of projects from your JIRA instance. The project list can be useful for features where you need to relate a particular issue to multiple projects or clone an issue under multiple projects.

Pranshu Goyal, Director of Products at Mirekta, states: “We envision DSM to be used by every small to a medium-sized organization dealing with bad data and want to get rid of duplicates easily with no cost. We have faced issues dealing with duplicates in our organization. That inspired us to make a solution that is not only simple to use but can be used widely to make the organization’s data clean to make them more efficient and productive. We want DSM to be a solution for every organization looking for duplicate management capability better than the Salesforce out-of-the-box solution with no additional cost.”

Getting the list of projects from JIRA database is a fairly straight forward task. Follow these steps to get the list:

First import the required classes in your java file where you want to fetch all the current JIRA projects. Here are the commands for the importing files

  • import com.atlassian.jira.project.Project;
  • import com.atlassian.jira.component.ComponentAccessor;

Now in the file, where you need to get the list of all current projects, write the following code

  • List projects=ComponentAccessor.getProjectManager().getProjectObjects();

Here the object projects is an Array List of type com.atlassian.jira.project.Project. You can get all the information of the projects from this ArrayList. Simple enough?

Recent Posts

Categories

Featured by