I'm pretty new to jira and I'm trying to write a query that pulls scoped stories and defects from our current sprint that are tagged for Fix version A and Fix version B (to clarify I'm not trying to pull stories that are tagged with both but just all that have either or). I've got that part down but now I'm also trying to include tasks from our current sprint tagged for Fix version A and fix version B that only have label A or Label B. Pasting a copy of the query below.
Query for stories and defects
project = XXX AND issuetype in (Defect, Story) AND (fixVersion = "Release 4.11" AND Sprint in (34438,34508)) OR issuetype in (Defect, Story) AND (fixVersion = "PEP Milestone 2" AND Sprint in (34438,34508))
Query to add in tasks with certain labels
AND issuetype in (Task) OR (fixVersion = "Release 4.11" AND Sprint in (34438,34508) AND (labels = Cloud) OR (labels = Non-Cloud-Application-Task)) OR issuetype in (Task) AND (fixVersion = "PEP Milestone 2" AND Sprint in (34438,34508) AND (labels = Cloud) OR (labels = Non-Cloud-Application-Task))
When I add this to the orginal query for stories and defects it does include the tasks with those labels but in doing so it removes the stories from the orginal query that are tagged for "PEP Milestone 2". How can I add the tasks with Label A and B without impacting the original Query?
Thanks!
Hello @Jeffery Mangold
Welcome to the Atlassian community.
Can you share with us the final combined query that is not getting what you want?
The problem could be related to your parentheses, but we need to see the actual query to determine if that is the case.
You can simplify your first query by using the IN operator with fixVersion, and your second query by using IN with the Labels field.
Do I understand correctly that you want
- Defects and Stories from specified sprints where the fix version is any one of a set of specified values,
PLUS
- Tasks from specified sprints where the fix version is any one of a set of specified values, and the Labels on the Tasks contain any one or more values from a set of specified values.
If I have understood correctly then the following query should work. I used indentation to help illustrate the structure.
project = XXX AND
fixVersion in ("Release 4.11","PEP Milestone 2") AND
Sprint in (34438,34508) AND
(
issuetype in (Defect, Story)
OR
(
issuetype in (Task) AND
labels in (Cloud, Non-Cloud-Application-Task)
)
)
For all the issues you want, they all should be in project XXX, have one of the specified Fix Version values, and be in one of the specified sprints. So those criteria can all be called out up front.
Next you want to get two different sets of issues types that meet those first criteria.
Set A is Defects and Stories. You don't have any additional criteria for those.
Set B is Tasks, and you have the additional criteria on Tasks that they need to have one or more Labels values from a set you specify.
To get issues from Set A and Set B you need the OR operator; issue that match the criteria of Set A or match the criteria of Set B.
When using AND and OR it is important to correctly place parentheses to encapsulate the related criteria. Lines 7 and 10 encapsulate the criteria of Set B as one group.
Lines 4 and 11 encapsulate the criteria for Set A and Set B, and with the preceding AND tells jira the then apply to those issues the project, fixVersion, and Sprint criteria.
In the labels clauses:
set them as:
You might need an extra set of brackets.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.