Sonarqube - GitLab integration PR decorator - branch with existing PR

Hi,

I was able to integrate Sonarqube 8.3 to GitLab and set GitLab CI pipeline to run build with sonar analysis for both branch (after each push) and for merge request. Ci pipeline task has “only” set as follows:
only:

  • merge_requests # to run for merge requests
  • /^.*$/ # to run for each branch

As a result if there is already created merge request for some branch, after next push to GitLab 2 new pipelines will be started. One for branch and one for merge request. They have the same definition, so analysis will have the same results. Since GitLab runner has limited resources, I wonder if there is a way to reuse results from branch analysis for PR decoration.

I guess there is no such configuration. Yet I was hoping, that maybe with some WEB API call, I would be able to print PR decoration message with results from some branch analysis to specific merge request. Or something similar. Such API would allow something like:

  1. Branch pipeline would decorate any existing MR for that branch
  2. When new MR, it would check if pipeline some pipeline for that branch is currently running. If not it would make sonar to decorate PR with last analysis result. If pipeline is running, it will do the decoration.

So far I failed to find any web API call that would allow something like this. So I thought I would try to ask if something like this is possible.

Thank you for any response

Hi,

Welcome to the community!

Sorry, there’s not. The expectation is really that if you’re using PRs/MRs, you’ll configure the analysis only of those and not of the underlying branches.

 
HTH,
Ann

Hi,
I was afraid this will be the case. Nevertheless thank you for quick answer.