Get list of project name, project lead, project key using java api


I'm trying to use Java API to get a list project name, project lead, project key by using groovy ScriptRunner. Do you have any example of my queries.


2 answers

Hi Dung,

You can do this using the project manager and looping over the projectObjects to get the information that you require.

I have attached a sample script that you can modify along with a screenshot of what its output looks like.


import com.atlassian.jira.component.ComponentAccessor

// Get the Project Manager
def projectManager = ComponentAccessor.getProjectManager()

// Iterate over each Project Object
def project = projectManager.getProjectObjects().each {project->

// Return information for each project object
return "Project Names: " + "<br/>" + + "<br/>" + "Project Keys: " + "<br/>" +  project.key + "<br/>" + "Project Leads: " + "<br/>" +

Sample Output:

Screen Shot 2016-10-21 at 15.57.42.png

I hope this helps.


0 votes
Mahesh S Community Champion Oct 20, 2016

Here is an example. Cheers!

import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.user.ApplicationUsers        
import java.util.Collections

Project myProject = issue.getProjectObject()
def leads 
def projectName, projectKey
leads = myProject.getProjectLead()
projectName = issue.getProjectObject().getName();
projectKey = issue.getProjectObject().getKey();
return "projectName is " + projectName + ", Project Key is " + projectKey+ ", Leads are " + leads

Hi Mahesh,

Thanks. But what I need is to get all the projects. As I understand, your code need to have issue object to the project name, project lead and key.

I want to run the code in Script Console.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,782 views 11 18
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot