It all plays well. I was expecting a deeper integration (where I don’t need to add those parameters, but SonarQube detects new Merge Requests and triggers the right build, but I know it would require a 3-way integration that will also have some complex configuration).
But I want to achieve something automatic, so when a PR is created in gitlab, a Jenkins build is triggered with the right parameters (Values needed would be the sonar.pullrequest.key and sonar.pullrequest.base values).
I believe the 8.x gitlab PR decoration plays very well with Gitlab CI/CD, but we are a lot of people using Jenkins out there, and it would be really useful if somebody has already worked out how to integrate this in Jenkins.
Our scanner can auto-detect these values if one of the corresponding Branch Source plugins is installed. For GitLab, this would be GitLab Branch Source. You would then need to make sure your Jenkins job is a Multibranch Pipeline job, and use this GitLab Branch Source plugin as the branch source.
Coincidentally, we’re in fact in the process of updating our documentation with more info on this. It should get deployed by the end of this week (or, if you don’t mind reading raw markdown, you can see the source page here before it gets deployed).
Let me know how it goes with the branch source plugin.
This helped to trigger jobs when we have a merge request, using Gitlab Plugin + Gitlab Branch Source plugin, but I cannot find variables that do the following
So still stuck. It looks like those variables (or similar variables) are not around for multibranch pipeline jobs…I’ll continue looking into options.
There is another plugin called " Gitlab Merge Request Builder Plugin" that brings some variables, but it’s not for multibranch pipelines, hence it does not look that interesting as using “Gitlab Branch Source”.
I’ve found there’s another variable called env.BRANCH_NAME that contains the branch name, or MR-key if it’s a Merge Request…so as long as we don’t call our git branches MR-xxxx, we can differentiate them by that variable…