Does ScriptRunner help to find empty projects

With JIRA JQL I cannot find empty projects i.e. projects without issues, as from my knowledge. Does ScriptRunner support it? Would be great.

3 answers

1 accepted

0 votes
Stephen Deutsch Community Champion Jul 24, 2017

I'm not sure what you meant by needing to learn to use the REST API, as the script that I provided uses the REST API to do all the work for you, so there's no need to learn how to use it.

The script that I provided doesn't work in the Scriptrunner console, it works in the browser console. However, I spent some time writing a script that you can run in the Scriptrunner console:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.project.ProjectManager

ProjectManager projectManager = ComponentAccessor.getProjectManager()
IssueManager issueManager = ComponentAccessor.getIssueManager()

return projectManager.getProjects().findAll { issueManager.getIssueCountForProject( == 0 }.collect { + " - " + it.key }

It will return a list of projects that don't have any issues.

Many thanks for the help! Fantastically.

0 votes
Stephen Deutsch Community Champion Jul 21, 2017

You don't necessarily need scriptrunner for this. Here's a script that you can paste into your browser console that uses the REST API to search all projects for the number of issues. If the project is empty, then it also displays the URL for the project (shows as link in Google Chrome):

var searchProjects = function(projects, size) {
var project = projects.pop();
url: contextPath + '/rest/api/2/search?jql=project="' + project.key + '"&maxResults=0',
success: function( response ) {
console.log("Project " + + " - " + (size - projects.length) + " of " + size + " contains " + + " issues.");
if ( === 0) {
console.log(AJS.params.baseURL + "/browse/" + project.key);
if (projects.length) {
searchProjects(projects, size);
error: function() {
console.log("Error loading project " + + " - " + (size - projects.length) + " of " + size)
if (projects.length) {
searchProjects(projects, size);

url: contextPath + '/rest/api/2/project?expand=url',
success: function( response ) {
delete response["length"];
searchProjects(response, response.length);


Thanks for the answer, but I am looking for the possibitlity to use the Jira adavanced search, since I am more familiar with that. So I thought, with ScriptRunner it could work.

Stephen Deutsch Community Champion Jul 21, 2017

Unfortunately there's no easy way to do this, because JQL is designed to return issues, not projects. You may be able to script something with scriptrunner and run it in the script console, but by that point you'd probably just be better off using the script I provided.

I got your point, but as mentioned, I have to learn to use the REST API. With ScriptRunner there is a Script Console, but the try was not successful:

startup failed: Script5.groovy: 1: expecting EOF, found 'searchProjects' @ line 1, column 5. var searchProjects = function(projects, size) { ^ 1 error


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,859 views 12 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