diff --git a/CHANGELOG.md b/CHANGELOG.md index 81b7959..6e5fd69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [0.0.31] - 2018-01-23 + +### Fixed + +- Support old SonarQube servers that don't report the server version in sonar-report.txt [(#11)(https://github.com/cathive/concourse-sonarqube-resource/issues/11)] + ## [0.0.30] - 2018-01-18 ### Added diff --git a/Dockerfile b/Dockerfile index 4f2b7ad..e666710 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,7 +36,7 @@ RUN mvn -q org.apache.maven.plugins:maven-dependency-plugin:3.0.2:get \ ENV PATH="/usr/local/bin:/usr/bin:/bin" LABEL maintainer="headcr4sh@gmail.com" \ - version="0.0.30" + version="0.0.31" COPY ./assets/* /opt/resource/ diff --git a/assets/common.sh b/assets/common.sh index bb94ba9..d2418f6 100644 --- a/assets/common.sh +++ b/assets/common.sh @@ -17,7 +17,7 @@ function read_properties { # Checks on a compute engine task # Params: -# $1 - Username or Access token, a colon ans optional the password, e.g. "user:password" (required) +# $1 - Username or Access token, a colon and optional the password, e.g. "user:password" (required) # $2 - SonarQube URL. Must end with a slash (required) # $3 - CE Task ID (required) function sq_ce_task { @@ -26,9 +26,17 @@ function sq_ce_task { # Checks the quality gate status of a project # Params: -# $1 - Username or Access token, a colon ans optional the password, e.g. "user:password" (required) +# $1 - Username or Access token, a colon and optional the password, e.g. "user:password" (required) # $2 - SonarQube URL. Must end with a slash (required) # $3 - Analysis ID (required) function sq_qualitygates_project_status { curl -s -L -u "${1}" "${2}api/qualitygates/project_status?analysisId=${3}" +} + +# Retrieves the version of a SonarQube server instance +# Params: +# $1 - Username or Access token, a colon and optional the password, e.g. "user:password" (required) +# $2 - SonarQube URL. Must end with a slash (required) +function sq_server_version { + curl -s -L -u "${1}" "${2}api/server/version" } \ No newline at end of file diff --git a/assets/out b/assets/out index 08486d2..2cb6ef2 100755 --- a/assets/out +++ b/assets/out @@ -158,6 +158,12 @@ eval "${scanner_bin} ${scanner_opts}" echo "Reading SonarQube scanner report (${scanner_report_file})..." if [ -f "${scanner_report_file}" ]; then eval "$(read_properties "${scanner_report_file}")" + if [ -z "${serverVersion:-}" ]; then + # Older versions of SonarQube don't store the serverVersion in + # sonar-report.txt. There is a REST API though, that can be used + # to fetch the version. + serverVersion="$(sq_server_version "${sonar_login}":"${sonar_password}" "${sonar_host_url}")" + fi else echo "error: SonarQube report could not be located." exit 1