Similar issue to https://community.sonarsource.com/t/sonarcloudprepare-3-0-3-no-longer-respects-sonar-projectbasedir/129656
Except with scannerMode: ‘CLI’
- task: SonarCloudPrepare@3
displayName: 'SonarScan Prepare cli analysis configuration'
inputs:
SonarCloud: 'SonarCloud'
organization: '<myorgid>'
scannerMode: 'CLI'
configMode: 'manual'
projectKey: '${{ parameters.sonarProjectKey }}'
projectVersion: '${{ parameters.buildNumber }}'
cliProjectKey: '${{ parameters.sonarProjectKey }}'
cliSources: '${{ parameters.sonarSources }}'
extraProperties: |
sonar.verbose=true
sonar.projectBaseDir=${{parameters.sonarProjectBaseDir}}
# Build and test npm app
- task: SonarCloudAnalyze@3 # Here it breaks
Where parameters.sonarProjectBaseDir is E:\agent_work\7\s\ProjectName
and parameters.sonarSources is src\react\React.Web
Builds ends in an error.
14:34:51.115 ERROR Invalid value of sonar.sources for <projectkey>
##[error]14:34:51.139 ERROR The folder 'E:\agent\_work\7\s\src\react\React.Web' does not exist for '<projectkey>' (base directory = E:\agent\_work\7\s\ProjectName)
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
...
Caused by: org.sonar.api.utils.MessageException: The folder 'E:\agent\_work\7\s\src\react\React.Web' does not exist for '<projectkey>' (base directory = E:\agent\_work\7\s\ProjectName)
Scanner should scan in E:\agent_work\7\s\ProjectName\src\react\React.Web, but it is trying to scan folder E:\agent_work\7\s\src\react\React.Web.
It clearly has the correct base directory E:\agent_work\7\s\ProjectName.
This has worked with SonarCloudPrepare@2 version with the following configuration
- task: SonarCloudPrepare@2
displayName: 'SonarScan Prepare cli analysis configuration'
inputs:
SonarCloud: 'SonarCloud'
organization: '<myorgid>'
scannerMode: 'CLI'
configMode: 'manual'
projectKey: '${{ parameters.sonarProjectKey }}'
projectVersion: '${{ parameters.buildNumber }}'
cliProjectKey: '${{ parameters.sonarProjectKey }}'
extraProperties: |
sonar.verbose=true
sonar.projectBaseDir=${{ parameters.sonarProjectBaseDir }}
sonar.sources=${{ parameters.sonarSources }}