cathive / concourse-sonarqube-resource

performs SonarQube analyses and checks quality gates https://concourse-ci.org/ https://sonarqube.org/
Apache License 2.0
46 stars 50 forks source link

Performing a "maven" Scan with "Debug" Set to True Fails #69

Closed rcsalome closed 2 years ago

rcsalome commented 3 years ago

When performing a scan with the "maven" type and "__debug: true", the following error is reported:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  04:18 min
[INFO] Finished at: 2021-01-08T18:05:03Z
[INFO] ------------------------------------------------------------------------/sonar/report-task.txt ]]
+ echo 'error: SonarQube report could not be located.'
error: SonarQube report could not be located.
+ exit 1

The resource is not able to find the generated report. Backtracking a bit, we find the following in the Concourse log output:

+ scanner_type=maven
+ [[ maven == \c\l\i ]]
+ [[ maven == \m\a\v\e\n ]]
+ mvn=mvn
+ [[ true == \t\r\u\e ]]
+ mvn+=' -X'
+ [[ -n '' ]]
+ scanner_bin='mvn -X'
+ [[ true != \t\r\u\e ]]
++ jq -r '.params.sonar_maven_plugin_version // ""'
+ sonar_maven_plugin_version=
+ [[ -n '' ]]
+ scanner_bin='mvn -X sonar:sonar'
++ mvn -X -q -f /tmp/build/put/updated-repo/pom.xml -Dexec.executable=echo '-Dexec.args=${project.build.directory}' --non-recursive exec:exec
+ maven_project_build_directory='Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)

Specifically, this line is important:

maven_project_build_directory='Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)

The reason for that is that the mvn -X portion is outputing debug information, and the extra output is mistakenly being set as the maven_project_build_directory

Here is the code portion in full: https://github.com/cathive/concourse-sonarqube-resource/blob/27a00c69ef2044d79c3f90175908b4b78db58fcd/assets/out#L246-L275

headcr4sh commented 2 years ago

Release v0.14.0 contains your bugfix, @rcsalome! Thanks for the contribution!!