Jira API list all projects using a workflow

Joel Batac August 21, 2022

I need help getting the list of projects using a specific workflow. Is there any API for this? If none, how do I go about achieving this?

2 answers

1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 21, 2022

Not a direct one.  You will have to replicate broadly what an admin would have to do in the UI:

  • read the project list and work out what workflow scheme each one is using and what issue type scheme it has.
  • cross-reference which workflows are being attached to each issue type in the issue type scheme (just because a workflow is mapped in a scheme, doesn't mean the project actually uses it)

In the UI however, this is a doddle, it does it for you.  Go to Admin -> Workflows to see the list, and you'll see it tells you what projects are using the workflow.

I'd want to question why you think you need a list like this over an API though - what are you wanting the list for?

Joel Batac August 23, 2022

HI Nic,

 Thanks for the reply.  My goal is to have newly created project that are using the workflow added to behaviour mapping.

 I asked before how to automatically check the workflow used by a project and assign the proper behaviour. I was given an answer to use REST Endpoint  but it uses Basic authentication - our jira doesn't support this. After that I was given where you can hard code token; our token rotates/changes every hour. So that's not possible either. 

 My thinking is to get the current list of projects using the workflow via API/python and schedule it once a day  to get the current list of projects (save the list to a file) and check if there's a newly project added. If there is, run an API to add the new project to the behaviour mapping (this is another thing I am researching). 

 

 I hope i explained my self clearly :)

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 23, 2022

Changing the workflow setup of an existing project is not something you want to code for - it is a LOT of work, you'll need to do all the checks for change of status and step in the os workflow stuff, migrating the issues and you'll need to fail the process to ask the users if there are migrations needed.

0 votes
V Varun
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 22, 2024

You can Get the list of projects associated with Workflow using Scriptrunner

 

This is for Jira Data Center

 

import com.atlassian.jira.component.ComponentAccessor
def projectManager = ComponentAccessor.projectManager
def workflowManager = ComponentAccessor.workflowManager
def workflowSchemeManager = ComponentAccessor.workflowSchemeManager
def sb = new StringBuffer()
 
def wfName = "" //workflow to search for
 
//a place to store results
def projects = []
//for each workflow scheme in Jira, find ones that contain our specified workflow workflowSchemeManager.assignableSchemes.each {
workflowSchemeManager.assignableSchemes.each{
    if (wfName in it.mappings.values()) {
    //add the project tied to this workflow scheme to our results
    projects.add(workflowSchemeManager.getProjectsUsing(it))
  }
}
 
projects.each {
    sb.append(it.toString())
 }
 
return sb.toString()

Suggest an answer

Log in or Sign up to answer