We have a unique requirement. A repository consists of the following folder structure:
Branch A - A/*A.java
Branch B - B/B.java
We are using ‘Bitbucket pull request trigger’ module in Jenkins to trigger the Jenkins build and perform the Sonarcloud analysis for every PR created in Bitbucket.
As a part of this, in Jenkins under Analysis properties ( in Execute sonarQube scanner) , we have mentioned the sonar.host.url=https://sonarcloud.io and other necessary parameters along with sonar.sources=A/,B/
Now, if we make changes in Branch A and raise a pull request in bitbucket under A/A.java folder, the build is triggering automatically in Jenkins but it is failing since the folder-B is not present in Branch-A on sonar.sources we are landing with this error:
ERROR: The folder ‘B/’ does not exist for '***** (base directory = …)
If we remove the folder - B in Analysis properties ( in Execute sonarQube scanner) its works fine. But whenever we create a PR in folder B, the Jenkins job fails again saying that there is no Folder - B to perform the scan results.
So how to get rid of this error? Can we consider the folders which are in the specific branch during Sonarcloud scan and ignore the extra folders which are mentioned in the Sonar.sources?