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

maven_settings_file parameter relative path logic is not working properly. #65

Closed cyclump closed 3 years ago

cyclump commented 4 years ago

When using the maven_settings_file parameter the code on line 82 checks for the existence of the file relative to the root directory of /tmp/build/put. On lines 290-292 when the maven command is invoked, the code changes to the directly first then evals the command line.

Given this, when using

  - put: code-analysis
    params:
      project_path: sonarqube-analysis-input
      scanner_type: maven
      project_key: my-key
      project_name: my name
      maven_settings_file: sonarqube-analysis-input/maven_settings.xml

maven cannot find the settings file because it is in the project directlory. You get this error:

Preparing SonarQube scanner...
Using Maven settings file: "sonarqube-analysis-input/maven_settings.xml"...
Starting sonar-scanner (type: maven)...
[ERROR] Error executing Maven.
[ERROR] The specified user settings file does not exist: /tmp/build/put/sonarqube-analysis-input/sonarqube-analysis-input/maven_settings.xml
ERROR in /opt/resource/out : line 292 with exit code 1

If you change the settings file by removing the directory, the code on line 82 can't find the file and stops with an error.

  - put: code-analysis
    params:
      project_path: sonarqube-analysis-input
      scanner_type: maven
      project_key: my-key
      project_name: my name
      maven_settings_file: maven_settings.xml

yeilds error: Maven settings file not found: maven_settings.xml.

The only way to make it work is to not use relative paths with requires you to use `/tmp/build/put' on the front of the file. This seems wrong as you are putting concourse specifics details into the YAML definition.