Hi @Vasco
You’ve hit a well-known JQL limitation—the project field doesn’t support wildcard or regex matching. Your regex workaround in code is actually a reasonable approach, but let me outline the options:
Options to Consider
1. Project Categories (Recommended if feasible)
If you can organise all your “PN-*” projects under a dedicated Jira category, you can use jql
category = "Your-PN-Category"
This is the cleanest JQL-native solution and would scale automatically as new PN-* projects are added.
2. Dynamic JQL via API
Use the Jira REST API to first fetch all projects, filter those starting with “PN-”, then programmatically build your JQL:
jql
project IN ("PN-999999", "PN-888888", "PN-777777", ...)
This could be regenerated periodically or on-demand.
Cons: you may hit JQL length limits (~65k chars)
3. Your Current Code-Level Filtering
Your regex approach is valid and flexible:
groovy
if ((issue.project?.name ==~ /PN-.*/)) {
// sync logic
}
Pros: Simple, works reliably, handles edge cases like “PNull”
Cons: You’re still fetching/processing issues you’ll discard, which may impact performance at scale
4. Label or Custom Field Trigger (Hybrid)
Add a specific label (e.g., sync-to-ado) to relevant projects and combine:
jql
labels = "sync-to-ado"
Then keep your regex as a safety check.
My Recommendation
Given you’re syncing Jira Cloud → ADO with hundreds of projects:
-
If you control project setup: Use Project Categories—it’s the most maintainable solution
-
If categories aren’t practical: Your current approach (label trigger + regex validation) is solid. The regex ensures you don’t accidentally sync “PNull” projects
Let me know if you need any further assistance.
Thanks,
Sonal