Skip to content

Commit

Permalink
fix PID file option on SonarQube 9.6, fixes #24
Browse files Browse the repository at this point in the history
  • Loading branch information
fraenki committed Jan 3, 2023
1 parent f8dd222 commit 359cff2
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 20 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ 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).

## [Unreleased]

### Changed
- Run acceptance tests with latest version 9.8.0

### Fixed
- Fix setting PID file location on SonarQube 9.6 and later ([#24])

## [5.0.0] - 2022-10-31
This is a new major release and contains breaking changes. Of note is the
new requirement to specify the `$version` parameter using SonarQubes
Expand Down Expand Up @@ -135,6 +143,7 @@ migrate from maestrodev/sonarqube to this version with only minor modifications.
[4.0.0]: https://github.com/markt-de/puppet-sonarqube/compare/v3.1.0...v4.0.0
[3.1.0]: https://github.com/markt-de/puppet-sonarqube/compare/v3.0.0...v3.1.0
[3.0.0]: https://github.com/markt-de/puppet-sonarqube/compare/v2.6.7...v3.0.0
[#24]: https://github.com/markt-de/puppet-sonarqube/pull/24
[#23]: https://github.com/markt-de/puppet-sonarqube/pull/23
[#22]: https://github.com/markt-de/puppet-sonarqube/pull/22
[#21]: https://github.com/markt-de/puppet-sonarqube/pull/21
Expand Down
41 changes: 26 additions & 15 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,32 @@
group => $sonarqube::group,
}

file_line { 'set PIDDIR in startup script':
ensure => present,
path => $sonarqube::script,
line => "PIDDIR=${sonarqube::home}",
match => '^PIDDIR=',
multiple => true,
}
-> file_line { 'set RUN_AS_USER in startup script':
ensure => present,
path => $sonarqube::script,
line => "RUN_AS_USER=${sonarqube::user}",
match => '^RUN_AS_USER=',
# insert after PIDDIR of no match is found
after => '^PIDDIR=',
multiple => true,
# SonarQube version 9.6 introduced breaking changes in the startup script.
if (versioncmp($sonarqube::version, '9.6') >= 0) {
file_line { 'set PIDFILE in startup script':
ensure => present,
path => $sonarqube::script,
line => "PIDFILE=${sonarqube::home}/${sonarqube::pidfile}",
match => '^PIDFILE=',
multiple => true,
}
} else {
file_line { 'set PIDDIR in startup script':
ensure => present,
path => $sonarqube::script,
line => "PIDDIR=${sonarqube::home}",
match => '^PIDDIR=',
multiple => true,
}
-> file_line { 'set RUN_AS_USER in startup script':
ensure => present,
path => $sonarqube::script,
line => "RUN_AS_USER=${sonarqube::user}",
match => '^RUN_AS_USER=',
# insert after PIDDIR of no match is found
after => '^PIDDIR=',
multiple => true,
}
}

if ($sonarqube::manage_service) {
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/plugin_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper_acceptance'

describe 'sonarqube::plugin define' do
sonar_version = '8.9.9.56886'
sonar_version = '9.8.0.63668'
sonar_user = 'sonar'
sonar_group = 'sonar'
plugin_dir = '/var/local/sonar/extensions/plugins'
Expand Down
5 changes: 2 additions & 3 deletions spec/acceptance/sonarqube_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
ensure => link,
target => "${target_path}/jdk-11.0.6+10/bin/java",
}
#class { 'maven::maven': }
), catch_failures: true)
end

Expand Down Expand Up @@ -53,8 +52,8 @@
end
end

context 'when installing LTS version' do
let(:version) { '8.9.9.56886' }
context 'when installing latest version' do
let(:version) { '9.8.0.63668' }

it_behaves_like :sonar_common
end
Expand Down
30 changes: 29 additions & 1 deletion spec/classes/sonarqube_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
describe 'sonarqube' do
let(:sonar_properties) { '/usr/local/sonar/conf/sonar.properties' }
let(:sonar_version) { '8.9.9.56886' }
let(:sonar_version_latest) { '9.8.0.63668' }

context 'when installing LTS version', :compile do
let(:params) { { version: sonar_version.to_s } }
Expand All @@ -11,7 +12,34 @@
it { is_expected.to contain_class('sonarqube::config') }
it { is_expected.to contain_class('sonarqube::service') }

it { is_expected.to contain_archive('download sonarqube distribution').with_source('https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-8.9.9.56886.zip') }
it { is_expected.to contain_archive('download sonarqube distribution').with_source("https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-#{sonar_version}.zip") }

it {
is_expected.to contain_file_line('set PIDDIR in startup script').with(
match: '^PIDDIR=',
)
}
it {
is_expected.to contain_file_line('set RUN_AS_USER in startup script').with(
match: '^RUN_AS_USER=',
)
}
end

context 'when installing latest version', :compile do
let(:params) { { version: sonar_version_latest.to_s } }

it { is_expected.to contain_class('sonarqube::install') }
it { is_expected.to contain_class('sonarqube::config') }
it { is_expected.to contain_class('sonarqube::service') }

it { is_expected.to contain_archive('download sonarqube distribution').with_source("https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-#{sonar_version_latest}.zip") }

it {
is_expected.to contain_file_line('set PIDFILE in startup script').with(
match: '^PIDFILE=',
)
}
end

context 'when crowd configuration is supplied', :compile do
Expand Down

0 comments on commit 359cff2

Please sign in to comment.