I’m using the sonarqube analysis for our Angular application to analyze the typescript source code.
The Task (Marketplace Extension) is Version 4.
When using the configuration option “store configuration with my source source (sonar-project.properties)” the build fails, because SonarQube can’t read the main project configuration even though it is configured in the properties file.
I tried both relative and absolute path configurations. This is the latest: "${System.DefaultWorkingDirectory}/vsts/build/sonar-project.properties"
ERROR: Error during SonarQube Scanner execution
ERROR: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.sources
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
C:\vsts-agent\_work\_tasks\SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055\4.3.0\sonar-scanner\bin\sonar-scanner.bat failed with return code: 1
Even enabling the debug flag on the build pipeline didn’t provide anymore information except that there is no information being printed about the variables being loaded.
I also had a look at the typescript code and noticed that the properties might not be properly loaded that way. The confusing issue was, that even with debug enabled, the tl.getInput() calls did not log their intended debug output.
According to this piece of code (Scanner.ts from sonar-scanner-vsts repo)
public toSonarProps() {
if (this.cliMode === 'file') {
return { [PROP_NAMES.PROJECTSETTINGS]: this.data.projectSettings };
}
return {
[PROP_NAMES.PROJECTKEY]: this.data.projectKey,
[PROP_NAMES.PROJECTNAME]: this.data.projectName,
[PROP_NAMES.PROJECTVERSION]: this.data.projectVersion,
[PROP_NAMES.PROJECTSOURCES]: this.data.projectSources
};
}
The projectSettings (which is just the filename of the settings) is placed in the PROJECTSETTINGS variable, but this seems to be ignored by sonarqube.
Is there any way to debug this any further?
It would be really helpful for us, because we don’t want to inline the sonar properties in the build pipeline but instead have them as a file in our git repo.