Searching with JQL Functions
GitConnect for Jira adds five custom JQL functions so you can build searches, filters, and boards that combine Jira data with GitHub and GitLab activity.
How to Write the Query
Each function returns a list of issues, so you always use it with the issue field and the in or not in operator:
issue in hasBranch()
issue not in hasBranch()
Important: A function on its own, such as
hasOpenMergeRequest(), is not valid JQL. Jira shows the error "Expecting operator but got '('". Always start withissue inorissue not in.
issue = hasBranch() works the same as issue in hasBranch(), and issue != hasBranch() the same as issue not in hasBranch().
You can combine the functions with each other and with any standard JQL using AND, OR, and ORDER BY.
Available Functions
| Function | Arguments | Returns |
|---|---|---|
| hasCommitBy(text, projects) | Both optional | Issues with at least one linked commit. With text, only commits whose author name, author email, or commit message contains the text |
| hasBranch(text, projects) | Both optional | Issues with at least one linked branch. With text, only branches whose name contains the text |
| inRepository(path, projects) | Path required, projects optional | Issues with any linked activity in one repository. Use the repository's full path, e.g. my-org/my-repo or my-group/my-subgroup/my-repo |
| hasOpenMergeRequest("", projects) | Projects optional | Issues with at least one open pull request (GitHub) or merge request (GitLab) |
| hasFailedPipeline("", projects) | Projects optional | Issues with at least one failed CI/CD pipeline run (GitHub Actions or GitLab CI) |
The optional projects argument is described under Limiting a Function to Projects below.
Matching Rules
- Text arguments are not case-sensitive.
hasBranch("Feature")andhasBranch("feature")return the same issues. - hasCommitBy and hasBranch match part of the text.
hasBranch("feature")matchesfeature/login,PROJ-12-feature-search, and so on. - hasCommitBy uses the author name and email recorded in Git (
git config user.name/user.email). This can differ from the name shown in Jira, GitHub, or GitLab. If a name returns nothing, try the author's email or email domain instead. - inRepository needs the exact full path.
inRepository("my-repo")returns nothing - useinRepository("my-org/my-repo"). The path is shown under each branch in the Issue Activity panel and on the Manage Repositories page. - hasOpenMergeRequest and hasFailedPipeline have no search text. Their first argument is ignored. Pass
""when you add a project list. - Project keys are not case-sensitive. Separate them with commas or spaces:
"PROJ, OPS"and"proj ops"are the same.
Limiting a Function to Projects
Jira runs a GitConnect function before it applies the rest of your query. In project = PROJ AND issue in hasBranch(), the function first collects matching issues from every project, and Jira then keeps the ones in PROJ. On most sites this makes no difference.
On sites with a lot of git activity, give the function a list of project keys as its second argument. It then reads only those projects, which is faster and keeps the result under the 1,000-issue limit:
issue in hasBranch("", "PROJ, OPS")
issue in hasCommitBy("jane.doe@example.com", "PROJ")
issue in hasOpenMergeRequest("", "PROJ, OPS")
issue in inRepository("my-org/my-repo", "PROJ")
- Use
""as the first argument when you don't want to filter by text - You can list up to 20 projects. Leave the list out to search every project
- A value that is not a project key shows an error, for example:
hasBranch(): "PROJ;" is not a project key
Sample Queries
Replace PROJ, repository paths, names, and emails with your own values.
Development Work on Issues
All issues in a project that have commits:
project = PROJ AND issue in hasCommitBy() ORDER BY updated DESC
Issues that are not Done but already have a branch - work in progress:
project = PROJ AND issue in hasBranch() AND statusCategory != Done
Issues marked In Progress with no branch yet - work that may not have started in code:
project = PROJ AND status = "In Progress" AND issue not in hasBranch()
Issues with commits but no branch linked - commits made directly on a shared branch:
project = PROJ AND issue in hasCommitBy() AND issue not in hasBranch()
Code Review
Issues with an open pull/merge request, oldest update first:
project = PROJ AND issue in hasOpenMergeRequest() ORDER BY updated ASC
Issues already marked Done that still have an open pull/merge request:
project = PROJ AND statusCategory = Done AND issue in hasOpenMergeRequest()
Issues with a branch but no open pull/merge request yet:
project = PROJ AND issue in hasBranch() AND issue not in hasOpenMergeRequest() AND statusCategory != Done
Builds and Pipelines
Issues with a failed pipeline in the current sprint:
project = PROJ AND sprint in openSprints() AND issue in hasFailedPipeline()
Issues with a failed pipeline and an open pull/merge request - reviews blocked by a broken build:
issue in hasFailedPipeline() AND issue in hasOpenMergeRequest()
By Repository
All issues with activity in one repository:
issue in inRepository("my-org/my-repo") ORDER BY updated DESC
Open pull/merge requests in one repository:
issue in inRepository("my-org/my-repo") AND issue in hasOpenMergeRequest()
Issues with commits in any repository except one:
issue in hasCommitBy() AND issue not in inRepository("my-org/my-repo")
Issues touched in either of two repositories:
issue in inRepository("my-org/frontend") OR issue in inRepository("my-org/backend")
By Author, Branch, or Commit Message
Issues with commits by an author (name or email):
issue in hasCommitBy("jane.doe@example.com") AND statusCategory != Done
Issues with commits from anyone at a company email domain:
issue in hasCommitBy("@example.com")
Issues with commits whose message contains "hotfix":
project = PROJ AND issue in hasCommitBy("hotfix")
Issues with a branch whose name contains "feature":
project = PROJ AND issue in hasBranch("feature")
Issues with a release branch:
issue in hasBranch("release/")
Using the Queries in Filters and Boards
- Open Jira's search from Filters in the sidebar or top navigation, and switch to JQL
- Paste a query and press Enter
- Click Save filter to reuse it, or use it as a board filter or a dashboard gadget source
Things to Know
- Results only include issues linked to a repository connected in GitConnect for Jira
- New branches, commits, and pull/merge requests show up in searches, saved filters, boards, and dashboards within about 5 minutes of GitConnect indexing them. Jira stores each function's result, and GitConnect refreshes the stored results every 5 minutes
- Each function returns at most 1,000 issues. Above that, Jira shows an error such as "hasBranch() matches more than 1,000 issues". Adding
project = PROJto the query does not help, because Jira applies it after the function runs. Add search text or a project list instead hasOpenMergeRequest(),hasFailedPipeline(), andinRepository()read at most 1,000 matching records across all projects, even when you give a project list- If GitConnect cannot read its data, Jira shows an error such as "hasBranch() could not read git data right now. Try the search again." It does not return an empty result
- On sites with a very large amount of git data,
hasBranch()orhasCommitBy()may show "has more git data than one search can read". List fewer projects in the second argument, or useinRepository() inRepository()with no argument is not allowed - Jira shows "Number of arguments passed to function 'inRepository' … is invalid"- Each function takes at most two arguments. A third argument shows "Number of arguments passed to function … is invalid"