How to create JQL filters for custom gitBranch field in Jira?

I’m trying to set up JQL filters for our custom gitBranch field in Jira. I can make simple filters like gitBranch = "main" or gitBranch IN("main") work fine. But I’m stuck when it comes to more complex conditions.

For example, I want to filter dev tickets like this:

gitBranch = "dev" AND NOT (gitBranch = "stage")

But any filter with NOT fails. I’ve got a test ticket in both ws-640 and dev branches, but I can’t seem to exclude it from certain results.

I also can’t get not in or != operators to work. Every time I try, Jira gives me an error.

Has anyone figured out how to use these more advanced conditions with custom fields? I’m out of ideas and could really use some help!

hey swiftcoder15, i’ve had similar issues. try using the ‘not contains’ operator instead of ‘!=’. something like:

gitBranch CONTAINS ‘dev’ AND NOT gitBranch CONTAINS ‘stage’

This worked for me with custom fields. hope it helps!

I’ve been wrestling with similar JQL challenges for our custom fields. One trick that’s worked wonders for me is using the ‘LIKE’ operator combined with wildcards. Try something like this:

gitBranch LIKE ‘%dev%’ AND gitBranch NOT LIKE ‘%stage%’

The ‘%’ acts as a wildcard, matching any characters before or after. This approach is more forgiving with partial matches and has helped me sidestep some of the limitations with custom fields.

Also, double-check your Jira admin settings. Sometimes, certain JQL functions are disabled for custom fields by default. If you have admin access or can chat with someone who does, it might be worth reviewing the field configuration to ensure all the operators you need are enabled.

Lastly, if all else fails, consider using a scripted JQL function if your Jira instance supports it. It’s a bit more advanced, but it can give you the flexibility to create complex filters that the standard JQL syntax might not support.

I’ve encountered this issue before when working with custom fields in Jira. One approach that’s proven effective is using the ‘IS NOT EMPTY’ condition in combination with other operators. Try structuring your query like this:

gitBranch IS NOT EMPTY AND gitBranch ~ ‘dev’ AND gitBranch !~ ‘stage’

The ‘~’ operator performs a contains search, while ‘!~’ is for ‘does not contain’. This method has worked well for me when dealing with complex filters on custom fields. It’s more flexible than exact matching and can handle multiple values in a single field. Remember to adjust the syntax based on your specific Jira version and field configuration.