-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from christianewillman/add-sonarqube-scanner-r…
…ecipe Add: SonarQube Scanner Recipe
- Loading branch information
Showing
5 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
default['sonarqube']['scanner']['mirror'] = 'https://sonarsource.bintray.com/Distribution/sonar-scanner-cli' | ||
default['sonarqube']['scanner']['version'] = '2.5' | ||
default['sonarqube']['scanner']['checksum'] = 'e2ec5f4b73aa7911f10518e304db3af0146a4347b8d06fc1d4a36b8baec0d8cc' | ||
|
||
default['sonarqube']['scanner']['host']['username'] = nil | ||
default['sonarqube']['scanner']['host']['password'] = nil | ||
default['sonarqube']['scanner']['host']['url'] = 'https://localhost:9000' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
sonarqube_scanner_mirror = node['sonarqube']['scanner']['mirror'] | ||
sonarqube_scanner_version = node['sonarqube']['scanner']['version'] | ||
sonarqube_scanner_checksum = node['sonarqube']['scanner']['checksum'] | ||
|
||
sonarqube_user = node['sonarqube']['user'] | ||
sonarqube_group = node['sonarqube']['group'] | ||
|
||
sonarqube_scanner_zipfile_destination = ::File.join(Chef::Config[:file_cache_path], "sonar-scanner-#{sonarqube_scanner_version}.zip") | ||
sonarqube_scanner_zipfile_source = "#{sonarqube_scanner_mirror}/sonar-scanner-#{sonarqube_scanner_version}.zip" | ||
|
||
sonarqube_scanner_root_dir = "/opt/sonar-scanner-#{sonarqube_scanner_version}" | ||
sonarqube_scanner_bin_dir = "#{sonarqube_scanner_root_dir}/bin" | ||
sonarqube_scanner_properties_file = "#{sonarqube_scanner_root_dir}/conf/sonar-runner.properties" | ||
sonarqube_scanner_profile_d_file = '/etc/profile.d/sonarqube-scanner.sh' | ||
|
||
group sonarqube_group do | ||
system true | ||
end | ||
|
||
user sonarqube_user do | ||
gid sonarqube_group | ||
system true | ||
end | ||
|
||
remote_file sonarqube_scanner_zipfile_destination do | ||
source sonarqube_scanner_zipfile_source | ||
mode 0644 | ||
checksum sonarqube_scanner_checksum | ||
end | ||
|
||
package 'unzip' | ||
|
||
bash 'unzip SonarQube Scanner' do | ||
code <<-EOF | ||
unzip #{sonarqube_scanner_zipfile_destination} -d /opt/ | ||
EOF | ||
not_if { ::File.exist?(sonarqube_scanner_root_dir) } | ||
end | ||
|
||
directory sonarqube_scanner_root_dir do | ||
recursive true | ||
mode 0755 | ||
owner sonarqube_user | ||
group sonarqube_group | ||
end | ||
|
||
template sonarqube_scanner_properties_file do | ||
source 'sonar-runner.properties.erb' | ||
mode 0700 | ||
owner sonarqube_user | ||
group sonarqube_group | ||
end | ||
|
||
template sonarqube_scanner_profile_d_file do | ||
source 'sonar-scanner.profile.d.erb' | ||
mode 0755 | ||
owner 'root' | ||
group 'root' | ||
variables( | ||
sonarqube_scanner_bin_dir: sonarqube_scanner_bin_dir, | ||
sonarqube_scanner_root_dir: sonarqube_scanner_root_dir | ||
) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Generated by Chef for <%= node['fqdn'] %> | ||
# Local modifications will be overwritten. | ||
|
||
#Configure here general information about the environment, such as SonarQube DB details for example | ||
#No information about specific project should appear here | ||
|
||
sonar.host.url=<%= node['sonarqube']['scanner']['host']['url'] %> | ||
<% if node['sonarqube']['scanner']['host']['username'] && node['sonarqube']['scanner']['host']['password'] -%> | ||
sonar.login=<%= node['sonarqube']['scanner']['host']['username'] %> | ||
sonar.password=<%= node['sonarqube']['scanner']['host']['password'] %> | ||
<% end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export PATH=$PATH:<%= @sonarqube_scanner_bin_dir %> | ||
export SONAR_RUNNER_HOME=<%= @sonarqube_scanner_root_dir %> |
20 changes: 20 additions & 0 deletions
20
test/integration/sonarqube_scanner/serverspec/assert_scanner_installation_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'serverspec' | ||
|
||
set :backend, :exec | ||
|
||
describe file('/opt/sonar-scanner-2.5') do | ||
it { should be_directory } | ||
it { should be_readable.by_user('sonarqube') } | ||
it { should be_executable.by_user('sonarqube') } | ||
end | ||
|
||
describe file('/opt/sonar-scanner-2.5/conf/sonar-runner.properties') do | ||
it { should be_file } | ||
it { should be_mode 700 } | ||
it { should be_owned_by 'sonarqube' } | ||
end | ||
|
||
describe file('/etc/profile.d/sonarqube-scanner.sh') do | ||
it { should be_file } | ||
it { should be_readable.by_user('root') } | ||
end |