I’m working on a JQL query to find issues that belong to epics with specific labels. Right now I can successfully filter by epic IDs like this:
project=DEV AND parentEpic in (DEV-1234, DEV-5678)
This works fine but the problem is that epic IDs change frequently since epics only last a few weeks in our workflow. Labels are much more stable and persistent.
I can easily find epics that have certain labels:
project=DEV AND issuetype=Epic AND labels in (TeamAlpha, TeamBeta)
What I really want to do is combine these two approaches. I want to find all issues whose parent epic has one of these labels. I tried nesting the queries but it doesn’t work:
project=DEV AND parentEpic in (labels in (TeamAlpha, TeamBeta))
Is there a way to achieve this kind of nested filtering in JQL? Maybe there’s an addon or different syntax that supports this?
Had this exact problem at my company and found a decent solution using the Structure plugin if you have it. The plugin adds advanced JQL functions for hierarchical filtering. With Structure, you can use issue in childrenOf("project=DEV AND issuetype=Epic AND labels in (TeamAlpha, TeamBeta)")
which does exactly what you’re after. Another approach that worked for us was setting up automation rules to automatically copy epic labels to all child issues when they’re created or moved. This way you can filter directly on story/task labels without referencing the parent epic. Takes some initial setup but makes querying way simpler long-term.
JQL doesn’t support nested queries like that - the syntax you tried won’t work because parentEpic needs specific issue keys, not query results. But there’s a workaround using two steps: first run your epic query to grab the actual keys, then plug those into your main query. I’ve automated this with a simple script that finds epics with specific labels, pulls their keys, and builds the final JQL query. Not as clean as a single query, but it works reliably and handles changing epic IDs automatically. Third-party apps like ScriptRunner also have enhanced JQL functions that might help here.
totally get ur frustation, jql can be a pain with that. what i did was create a saved filter for the epics based on labels then use that in your main query. it’s a bit of a workaround but might save u some time!