My maven project repo structure
I'm able to configure and run sonar-scanner in gitlab using below
SONAR SCAN:
image: maven:3.8-openjdk-11
stage: build
script:
- cd modules
- mvn clean install
- mvn sonar:sonar -Dsonar.qualitygate.wait=true -Dsonar.projectKey=<KEY> -Dsonar.host.url=<HOST_URL> -Dsonar.login=<LOGIN>
Since my javascript files were not detected by above:
I've tried this configuration
SONAR SCAN:
image: sonarsource/sonar-scanner-cli:latest
stage: build
script:
- apk add maven
- cd modules
- mvn package -DskipTests=true
- cd ..
- sonar-scanner -Dsonar.qualitygate.wait=true -Dsonar.projectKey=<> -Dsonar.java.binaries=modules/ -Dsonar.sources=ui-modules/ -Dsonar.host.url=<> -Dsonar.login=<>
But above configuration is not detecting java files. How to configure single job for running scan on ui-modules folder as well as modules folder?
You have to set all directories which you would like to scan via sonar.sources variable:
-Dsonar.sources=./ui-modules,./modules