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 and maven_settings_file question #64

Closed cyclump closed 3 years ago

cyclump commented 4 years ago

This issue refers to lines 70-90 in assets/out.

I am puzzled by the intent of the maven_settings parameter in the source config. The parameter is captured on line 73. If the value is found in the source config, the value specified is stored in a temp file and the name of the tempfile is stored in maven_settings_file. If it is not specified in the source, it is harvested from the parameters for the step and that value is stored in maven_settings_file.

This presents the same variable with potentially two different types of values.

My question is, when using maven_settings, is that supposed to be something like

resources:
- name: code-analysis
  type: sonar-runner
  source:
    login: <... token here ...>
    host_url: http://my-sonar.domain.net/
    maven_settings: |
        <?xml version="1.0" encoding="UTF-8"?>
        <settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <profiles>
            <profile>
            <repositories>
                <repository>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <id>central</id>
                <name>libs-release</name>
                <url>https://corporate-proxy-repo:443/artifactory/libs-release</url>
                </repository>
                <repository>
                <snapshots />
                <id>snapshots</id>
                <name>libs-snapshot</name>
                <url>https://corporate-proxy-repo:443/artifactory/libs-snapshot</url>
                </repository>
            </repositories> 
            <pluginRepositories>
                <pluginRepository>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <id>central</id>
                <name>libs-release</name>
                <url>https://corporate-proxy-repo:443/artifactory/libs-release</url>
                </pluginRepository>
                <pluginRepository>
                <snapshots />
                <id>snapshots</id>
                <name>libs-snapshot</name>
                <url>https://corporate-proxy-repo:443/artifactory/libs-snapshot</url>
                </pluginRepository>
            </pluginRepositories>
            <id>artifactory</id>
            </profile>
        </profiles>
        <activeProfiles>
            <activeProfile>artifactory</activeProfile>
        </activeProfiles>
        </settings>

Or is it supposed to just point to a file like

resources:
- name: code-analysis
  type: sonar-runner
  source:
    login: <... token here ...>
    host_url: http://my-sonar.domain.net/
    maven_settings: sonar-source-files/maven_settings.xml
headcr4sh commented 3 years ago

It is supposed to work as mentioned in your first example, thus: maven_settings should contain the complete contents of your maven settings.xml file, whereas maven_settings_file points to the location of your settings file.

headcr4sh commented 3 years ago

You are right, that the documentation is wrong about the order in which both parameters are being evaluated. I think it would be far better to throw an error if both parameters are specified as such a configuration will probably indicate that something is not quite right...