<img height="1" width="1" style="display:none;" alt="" src="https://px.ads.linkedin.com/collect/?pid=299788&amp;fmt=gif">

Finding Where Issue Types are Used the Quick Way

Atlassian, Jira

To run the below groovy scripts in this blog, you can use the Groovy Script Tester if you are utilizing JMWE.

Have you ever noticed how hard it is to quickly identify all Jira projects using a specific issue type?

I, for one, have found myself asking this basic question many times, whether I am in need of the data for myself or am collecting it for a client. Whether you look at the list of Issue Types or Issue Type Schemes, you may be surprised to find nothing that directly answers this question!

For example, in the Issue Types menu, you will see the Issue Type Schemes associated with each issue type, which is useful, but not the projects associated with that issue type!

Similarly, if you take a look at the Issue Type Schemes menu, you will see a list of projects and issue types per Issue Type Scheme, but determining which projects utilize a specific issue type is as tedious as untangling a heap of Christmas lights!

So, as you can anticipate, I automated this task to save myself (and hopefully you!) some time.

Again, the problem statement is: Which Projects use this Issue Type across my Jira instance? 

Take a look at the script below, which outputs a list of projects that use a specific issue type.

import com.atlassian.jira.component.ComponentAccessor
def schemeManager = ComponentAccessor.issueTypeScreenSchemeManager
def sb = new StringBuffer()
//replace with your issue type name
def issueTypeName = "Story"
//iterate over all projects in instance
>ComponentAccessor.getProjectManager().getProjectObjects().each{ project->
//iterate over issue types for this project
project.getIssueTypes().each{ issuetype->
def thisIssueTypeName = issuetype.name.toString()
//check if correct issue type
if(thisIssueTypeName == issueTypeName) { //output results sb.append("*${issueTypeName}* found in ${project}\n") } } } return sb.toString()

As you can see, the script above iterates over all projects in your instance and checks if it is using the Issue Type of your choosing. It then prints out the results. All you need to do is replace the issueTypeName value with the Issue Type you are searching for!

Here is some sample output from that script:


*Story* found in Project: THREE60
*Story* found in Project: SOACS
*Story* found in Project: RCT
*Story* found in Project: AGI
*Story* found in Project: ADMIN
*Story* found in Project: PROM
*Story* found in Project: AX

Now, one addition that could be useful for you is to also identify which Issue Type Screen Schemes are tied to a specific issue type. Yes, this is another task that may come up for you and you will (again) be surprised that there is no quick way to determine it within the Jira UI.

The problem statement here would be Which Issue Type Screen Schemes are tied to this Issue Type across my Jira instance?

You may be wondering why this would be useful or what the problem really is...so let me back up really quick to provide a use case. Recall that Issue Type Screen Schemes define which Screen Schemes apply to which Issue Types within a project. In effect, this means they determined which fields show up for a specific issue type in a project. So, say you want to add a field that MUST be shown for any QA issue type across your instance. How would you even begin to find everywhere this issue type is used and enumerate all the screens that you would need to add this field to? Being able to identify all the Issue Type Screen Schemes tied to an issue type would give you just that! And BONUS: with adding a few lines to my script below, you could easily output not only the Issue Type Screen Schemes, but drill down into the schemes and screens that are ultimately tied to this issue type, as well.

To show you how easy this is, let's take our original script from above and add a few lines to output the issue type screen schemes tied to the issue type as well.

import com.atlassian.jira.component.ComponentAccessor
def schemeManager = ComponentAccessor.issueTypeScreenSchemeManager
def sb = new StringBuffer()
//replace with your issue type name
def issueTypeName = "Story"
//iterate over all projects in instance
ComponentAccessor.getProjectManager().getProjectObjects().each{ project->
//iterate over issue types for this project
project.getIssueTypes().each{ issuetype->
def thisIssueTypeName = issuetype.name.toString()
//check if correct issue type
if(thisIssueTypeName == issueTypeName) {
//get issue type screen scheme name for project
def isss = schemeManager.getIssueTypeScreenScheme(project)
//output project and issue type screen scheme we found
sb.append("*${issueTypeName}* found in Project: ${project} with Issue Type Screen Scheme: ${isss.getName()}\n")
}
}
}
return sb.toString()
Here is some sample output from the above script:
*Story* found in Project: THREE60 with Issue Type Screen Scheme: Atlassian Services External Issue Type Screen Scheme
*Story* found in Project: SOACS with Issue Type Screen Scheme: Atlassian Services External Issue Type Screen Scheme
*Story* found in Project: RCT with Issue Type Screen Scheme: RCT: Kanban Issue Type Screen Scheme
*Story* found in Project: AGI with Issue Type Screen Scheme: Task-based Screen Scheme
*Story* found in Project: ADMIN with Issue Type Screen Scheme: Default Issue Type Screen Scheme
*Story* found in Project: PROM with Issue Type Screen Scheme: Default Issue Type Screen Scheme
*Story* found in Project: AX with Issue Type Screen Scheme: Default Issue Type Screen Scheme

In Conclusion, next time you find yourself needing this information on Issue Type usage within your Jira instance, don't forget to hop back over to my blog if you want to get this done the quick way. And as always, Happy Automating!

Managing JIRA at Scale White Paper

TAGS: Atlassian, Jira

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Subscribe to Our Newsletter

Recent Blog Posts