Filter issues that have only one specific label and no other labels

We have several labels on issues in my project.
E.g. A, B, C, D, ...

I want to find the issues that have label A and only label A.
That is, I dont want to find any issues having A + another label. Just the ones with A only.

And I dont want to list all other possible labels and exclude them, as in the following query. ( labels=A and labels not in (B,C,D...) )
This is not a good solution when there are a huge amount of other labels.

 

3 answers

1 vote

Off the shelf, you can't do it.

It is possible with code, and I've seen two approaches before

1.  A field that counts labels - your query becomes "labels = A and 'count of labels' = 1"

2.  A JQL function - your query becomes "labels = A and labelCount() = 1"

 

Both of these are really easy to implement if you've got ScriptRunner installed, I've done the field one with my own code and SR, and seen SR create the function as well.

Thank you for your answer. I have not worked much with JIRA.

Have I understood you correctly that for 1) I have to create an new field. How do I get this new field to count number of lables?

I dont think we have ScriptRunner installed. I will check with the administrators.

Correct - a scripted field in scriptrunner can be really simple, I suspect it can be done in one line of code for counting labels.

0 vote
Steven Behnke Community Champion Nov 13, 2017

I don't think it's possible to write a query like this out-of-the-box.

I am now trying to use:

issueFunction in issueFieldMatch("", "labels", "^A$")

but that doesnt work... Give no matches at all.

If I instead have:

issueFunction in issueFieldMatch("", "labels", "A")

ist find all issues with label A but also the issues with several labels.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

535 views 1 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