Need list of projects linked to any workflow

Jennifer Lobo June 12, 2019

Need list of projects linked to one workflow. 

I have checked the Administration -> Workflows -> Open workflow  Shows the list of associated workflows -> It also shows hidden projects and i cannot render the list from there 

I have also checked for any built in scripts in script runner , but was not a successful 

I was not able to find any existing REST API for the same . 

Note: My environment doesn't allow installing any new plugins 

Please suggest 

6 answers

4 votes
Ilya Turov
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.
June 12, 2019

if you have a scriptrunner, you can execute this piece in console :

import com.atlassian.jira.component.ComponentAccessor

def projectManager = ComponentAccessor.projectManager
def workflowManager = ComponentAccessor.workflowManager
def workflowSchemeManager = ComponentAccessor.workflowSchemeManager

def wfName = "GSEP Template Task Workflow"
def allProjects = projectManager.getProjectObjects()
allProjects.findAll { project ->
def scheme = workflowSchemeManager.getWorkflowScheme(project)
wfName in workflowManager.getWorkflowsFromScheme(scheme)*.name
}*.key

basically goes through all projects and checks if the workflow with such name is in its scheme

change "key" in a last row to "name" if you want list of project names, not keys

1 vote
Jennifer Lobo June 13, 2019

Hello , 

Im getting the attached message 

Capture4.PNG

Ilya Turov
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.
June 13, 2019

again, it's not really a error. 

the real error won't allow the script to work at all, but it works and returns empty list, which means that either the name of workflow I put there is incorrect and you have to manually edit it or that there is something drastically different between our jiras.

Jennifer Lobo June 18, 2019

Hello IIya , 

Thanks i was able to run this script and its working , it seems like there was a extra space in my workflow . 

Thanks for all your help  

1 vote
Jennifer Lobo June 12, 2019

Thanks Ilya , 

I have tried running the Script above , Im getting this as the result  , Can you help me out here . Capture2.PNG

Ilya Turov
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.
June 12, 2019

this warning is about using a deprecated method (still works though)

maybe, try copying and pasting the name of you workflow here (since i took it from a screenshot and might have mistyped something):

def wfName = "GSEP Template Task Workflow"
Ilya Turov
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.
June 12, 2019

aight, rewritten it a bit without using deprecated methods

maybe your jira version is newer than mine so for you those just dont work

try this (again, make sure you put proper workflow name in it):

import com.atlassian.jira.component.ComponentAccessor

def projectManager = ComponentAccessor.projectManager
def workflowManager = ComponentAccessor.workflowManager
def workflowSchemeManager = ComponentAccessor.workflowSchemeManager

def wfName = "GSEP Template Task Workflow"
def allSchemes = workflowSchemeManager.assignableSchemes
Set f = []
allSchemes.each {
if (wfName in it.mappings.values()) {
f += workflowSchemeManager.getProjectsUsing(it)
}
}
f*.key
Like # people like this
Jose Luis Casarrubias July 20, 2020

work like a charm

Like Nirmani Kalakheti likes this
0 votes
Gerald Remillard July 6, 2021

Go in the  Workflow schemes page.

0 votes
Jennifer Lobo June 12, 2019

I have tried that .

When clicked on the Workflow to check the Projects Linked to one workflow so when viewing it shows me that some of them are hidden  

Please find the snapshot . 

How do i find which are these hidden projects , I have more than 100+ Workflows and 500+ Projects 

Capture.PNG

0 votes
Deleted user June 12, 2019

Hi @Jennifer Lobo ,

 

To know the list of the projects that are using the same workflow: Navigate to the workflow section from the Administration section -> Issues -> click on the view of any workflow -> As shown in the below screenshot you can see a USED BY option at the top which will give you the list of workflows that are using the respective workflow.

 

community11.png

 

community12.png

 

Hope this helps you and not require any third-party add-ons.

 

Regards,

Sravya

Alicia Pena May 17, 2022

How do you see the hidden projects if there are more than 15 using a workflow.  If that workflow is being used by several schemes, it's not helpful to look up schemes.

Suggest an answer

Log in or Sign up to answer