-
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 #13 from christianewillman/add-plugin-lwrp
Add: SonarQube Plugin LWRP
- Loading branch information
Showing
5 changed files
with
66 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,3 @@ | ||
default['sonarqube']['plugin']['mirror'] = 'https://sonarsource.bintray.com/Distribution' | ||
|
||
default['sonarqube']['plugin']['dir'] = "/opt/sonarqube-#{node['sonarqube']['version']}/extensions/plugins" |
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,49 @@ | ||
property :plugin_name, String, name_property: true | ||
property :version, String | ||
|
||
actions :install, :uninstall | ||
default_action :install | ||
|
||
sonarqube_user = node['sonarqube']['user'] | ||
sonarqube_group = node['sonarqube']['group'] | ||
|
||
action :install do | ||
service 'sonarqube' do | ||
action :nothing | ||
end | ||
|
||
remote_file plugin_path do | ||
source plugin_url | ||
mode 0755 | ||
owner sonarqube_user | ||
group sonarqube_group | ||
notifies :restart, 'service[sonarqube]', :delayed | ||
end | ||
end | ||
|
||
action :uninstall do | ||
service 'sonarqube' do | ||
action :nothing | ||
end | ||
|
||
file plugin_path do | ||
action :delete | ||
notifies :restart, 'service[sonarqube]', :delayed | ||
end | ||
end | ||
|
||
def plugin_url | ||
sonarqube_plugin_mirror = node['sonarqube']['plugin']['mirror'] | ||
|
||
"#{sonarqube_plugin_mirror}/sonar-#{plugin_name}-plugin/#{plugin_file_name}" | ||
end | ||
|
||
def plugin_path | ||
sonarqube_plugin_dir = node['sonarqube']['plugin']['dir'] | ||
|
||
::File.join(sonarqube_plugin_dir, plugin_file_name) | ||
end | ||
|
||
def plugin_file_name | ||
"sonar-#{plugin_name}-plugin-#{version}.jar" | ||
end |
2 changes: 2 additions & 0 deletions
2
test/fixtures/cookbooks/sonarqube_plugin_consumer/metadata.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,2 @@ | ||
name 'sonarqube_plugin_consumer' | ||
depends 'sonarqube' |
3 changes: 3 additions & 0 deletions
3
test/fixtures/cookbooks/sonarqube_plugin_consumer/recipes/default.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,3 @@ | ||
sonarqube_plugin 'groovy' do | ||
version '1.3' | ||
end |
9 changes: 9 additions & 0 deletions
9
test/integration/sonarqube_plugin/serverspec/assert_plugin_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,9 @@ | ||
require 'serverspec' | ||
|
||
set :backend, :exec | ||
|
||
describe file('/opt/sonarqube-5.1.2/extensions/plugins/sonar-groovy-plugin-1.3.jar') do | ||
it { should be_file } | ||
it { should be_readable.by_user('sonarqube') } | ||
it { should be_executable.by_user('sonarqube') } | ||
end |