We are using the pipeline definition generated by the “wizard” of sonarcube cloud (see below). The only thing we had to change as the JDK because our application is not compatible with java 17. We dont use butbucket pipelines for any of our builds, so we are not familiar with it. We only use it because our build system is not supported by sonar.
Our main branch is develop. We only ever want to check PRs on develop, and we only want to do full branch analysis of develop. We would never want to do any kind of analysis on master, as master just a way to deploy.
In the supplied pipeline, it has this:
pipelines:
branches:
master:
- step: *build-test-sonarcloud
pull-requests:
'**':
- step: *build-test-sonarcloud
The question is, should this be changed?
e.g. should it be something like this?
pipelines:
branches:
develop:
- step: *build-test-sonarcloud
pull-requests:
'**':
- step: *build-test-sonarcloud
We assume ** means all branches. Is there any way to restrict it to just branches from develop? Otherwise every feature branch will be duplicate checked as it goes from develop->test->master, causing wasted pipeline cost and presumably a lot of unwanted duplicate information and branches in the sonar UI.
image: maven:3-jdk-11
clone:
depth: full # SonarQube Cloud scanner needs the full history to assign issues properly
definitions:
caches:
sonar: ~/.sonar/cache # Caching SonarQube Cloud artifacts will speed up your build
steps:
- step: &build-test-sonarcloud
name: Build, test and analyze on SonarQube Cloud
caches:
- maven
- sonar
script:
- mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
artifacts:
- target/**
pipelines:
branches:
master:
- step: *build-test-sonarcloud
pull-requests:
'**':
- step: *build-test-sonarcloud