shijl0925 / python-sonarqube-api

Python Client library for interacting with Community, Developer, and Enterprise Editions SonarQube's REST APIs and SonarCloud's REST APIs.
https://python-sonarqube-pro-api.readthedocs.io/en/latest/
GNU Affero General Public License v3.0
133 stars 77 forks source link

How to get status of current project? #76

Closed Abe410 closed 1 year ago

Abe410 commented 1 year ago

Hi,

I am using measures.get_component_with_specified_measures to connect to the relevant endpoint to get the metrics of a project.

Thing is, I am doing this right after I run a scan, and for bigger projects, this can take some time.

So for those projects, my script then fails and gives an error.

I could implement a time.sleep() method to pause execution of the script for a while, but this is not needed for smaller code scans.

Is there any way I can check from the API itself if the analysis and background tasks have been completed or not?

shijl0925 commented 1 year ago

You can use the search_tasks to get the background tasks status. for example: tasks = client.ce.search_tasks(componentId="AYPE5_SBK_hfsDL1XEIN", status="IN_PROGRESS,SUCCESS,FAILED,CANCELED")