SonarQube API search issues with componentKeys by directory

1.5k Views Asked by At

In the SonarQube docs it says that componentKeys can be the following:

Comma-separated list of component keys. Retrieve issues associated to a specific list of components (and all its descendants). A component can be a portfolio, project, module, directory or file.

I want to get all the issues from components of a specific directory. I have tried to use the * wildcard like this:

http://localhost:9000/api/issues/search?componentKeys=projectkey:src/testcases/*

or

http://localhost:9000/api/issues/search?componentKeys=src/testcases/*

This doesn't seem to work, how can you search issues by a directory?

2

There are 2 best solutions below

0
S.Siva On

You can pass your projectKey name as ComponentKeys and pull all the issues from the project.

http://localhost:9000/api/issues/search?componentKeys=testproject
0
Marco Gouveia On

You were very close. If you want to filter issues under src/testcases then you can use:

http://localhost:9000/api/issues/search?componentKeys=projectkey:src/testcases/%