Is it possible to fetch SonarQube projects based on GitHub Actions workflow or Jenkins build data?

Hello community,

I’m running SonarQube analysis on a project through both Jenkins and GitHub Actions. I would like to know if there’s a way to fetch SonarQube project analyses based on metadata from GitHub workflows (e.g., run ID, commit SHA) or Jenkins build numbers.

Is there any supported approach or recommended API usage to filter or search projects/analyses using:

  • GitHub workflow run details?
  • Jenkins build number or other job metadata?

Appreciate any guidance or suggestions on how to achieve this.

Thanks in advance!

Hey there.

I believe you are looking for sonar.buildString, which you can set to an environment variable like GITHUB_RUN_ID.

This isn’t possible retroactively, but might help going forward!

Hi there,

If I add sonar.buildString in the Jenkins script/workflow script and set it to something like the Jenkins build ID or workflow ID, can I later use the SonarQube API to find the related SonarQube project or analysis using that build ID or workflow ID without project name or key?

Thanks!

No, you’ll have to provide the project key to APIs like GET api/project_analyses/search. I guess it’s accurate to say that it makes it easier to correlate an analysis to a run, and not so much the other way around.

Thank you for this valuable information.