What value do i need to put for sonar.projectBaseDir and sonar.working.directory

Hi
i want to set sonar.projectBaseDir and sonar.working.directory since i need analysis to take place in a directory other than the one from which it was launched in bitbucket. those two paths are relative or absolute? and it should be relative. what value do I need to put?
these are the paths where the sonar scan is triggered in the root directory:

INFO: Base dir: /opt/atlassian/pipelines/agent/build
INFO: Working dir: /opt/atlassian/pipelines/agent/build/.scannerwork

this is the path for srouce code: https://bitbucket.org/aamc-org/mcat-email-service/src/25ff84864011b2883f121dbfcc8b2f49cc0c1fb6/

Besides these two arguments, are there any other arguments that need to be set for this situation? thank you so much

Best
James

Hey there.

Take a look at the documentation for this analysis parameter

sonar.projectBaseDir

Use this property when you need the analysis to take place in a directory other than the one from which it was launched. For example, analysis begins from jenkins/jobs/myjob/workspace but the files to be analyzed are in ftpdrop/cobol/project1 . The path may be relative or absolute. Specify not the source directory, but some ancestor of the source directory. The value specified here becomes the new “analysis directory”, and other paths are then specified as though the analysis were starting from that specified value. Note that the analysis process will need write permissions in this directory; it is where the sonar.working.directory will be created.

Default: The directory from which the SonarScanner is launched.

thank you Colin for the quick response. so it is a relative path or absolute path. could you please show me an example of sonar.projectBaseDir based on my situation? and what’s the best practice of sonar scan? in the root directory or different directory? thank you

James

1 Like

I’m currently stuck here as well. Not everyone is a pro, but lack of support is not helping the sonar community as my company couldn’t proceed to private due to sample project we weren’t able to setup

2 Likes