Jodocus Blog
Published in

Jodocus Blog

How to Generate a List of All Labels in a Jira Instance

Photo by Glenn Carstens-Peters on Unsplash

Jira labels are a great way to quickly categorize issues. Everyone can add labels and they can do so anytime. Labels can also be easily searched and filtered making them a great fit for dashboard widgets and reports.

But how to view all the labels used in Jira? And how to find how many times a label is used in Jira? No, you do not need to compile it by hand! You can do it with one easy Jira Expression, of course! This article will show you how to use a combination of JQL and Jira Expressions to find all labels used in Jira and how often they have been used.

You do not need any extra apps to follow along – everything can be done via the Jira Expression REST API. However, the easiest way to work with Jira Expressions is to use our free app, Expression Tester. You can install the Expression Tester from the Atlassian Marketplace.

Selecting all issues with a label

First, we need to find all the issues that have one or more labels assigned to them. We can do that with a super-short JQL query: labels is not EMPTY

This returns a list of issues that we can work with in a Jira Expression. Of course, there is a lot of info in that list and we just want the labels. So let’s use map() to only keep the label information and then flatten() to turn a list of lists into a single list:

issues.map(l => l.labels).flatten()

Pretty good, but not quite what we want. That list contains a lot of duplicates and it would be cool if we had some idea how may times a label has been used. Again, Jira Expressions to the rescue! As we have explained here, thereduce() function can help us by counting how many times it sees a label. Our final Jira Expression looks like this:

issues
.map(l => l.labels)
.flatten()
.reduce((result, label) =>
result.set( label, (result[label] || 0) + 1), new Map())

Putting that expression to work, we finally get a list of all labels in our Jira instance along with how many times they have been used:

A list of all labels in your Jira instance, available with the click of a button.

And there you go: A list of all labels in your Jira instance, available with the click of a button. And easily downloadable as a JSON object. Depending on how intensively your team uses labels, you will probably see a lot more labels and a lot higher numbers.

Do you have a lot of labels? Want an easy UI to manage labels? Then Project Labels might be the right app for you. Check it out on the Atlassian Marketplace.

Conclusion

This has been a really quick and easy way to get a rough overview of the labels in your Jira instance, but of course, there’s always a catch. If you are an expert with Jira and JQL you can probably already guess: There is an in-built limit to how many issues are returned in a single query. So, for large instances, our quick and easy way will not cut it. If you happen to hit that limit, there are two things you can do:

  1. Limit the number of issues returned by JQL. Either by selecting only issues from a specific project or from a certain date range.
  2. Get a label manager for Jira Cloud such as our own Project Labels. This handy tool takes care of everything behind the scenes, displays your labels and lets you rename and delete them at will.

Hopefully, this short article was helpful for you and showed how versatile Jira Expressions are. Do you have any cool use-case for Jira Expressions? Let us know!

--

--

--

Makers of Jira Cloud Apps :: Atlassian Solution Partner from Germany. This is our blog about Jira Cloud and Atlassian, about Processes, Workflows and how to get things done.

Recommended from Medium

Migrating Transactional Data to MongoDB in AWS with the Zaloni Arena Data Governance Platform

Make your premises smarter, safer and more sustainable with a unified smart building system

DEC64 — Douglas Crockford’s Decimal Notation

Why doesn’t my CSS rules apply?, CSS specificity

HOW TO DEPLOY A .NET CORE API TO AWS USING TERRAFORM AND DOCKER

Streaming Data Integration using Change Data Capture

Following Clues

Migrating From Magento 1.8 to Magento 2 — One Year After — Part 1

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Oliver Siebenmarck

Oliver Siebenmarck

Interested in cloud, machine learning, ALM and DevOps. λ-enthusiast. Lead Architect @jodocus_io

More from Medium

Approaches for Start and Resume Journey for User Onboarding to Platform (Part II)

My First Experience with AWS S3 Bucket (Story Time)

Decoding — StackExchange aka SEDE SQL Query for Sourcer and Recruiter

Why API Marketplaces Suck