Skip to content

Commit

Permalink
Merge pull request #13 from christianewillman/add-plugin-lwrp
Browse files Browse the repository at this point in the history
Add: SonarQube Plugin LWRP
  • Loading branch information
pghalliday committed Feb 16, 2016
2 parents 17e15a9 + 8d817d0 commit c7f3452
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 0 deletions.
3 changes: 3 additions & 0 deletions attributes/plugin.rb
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"
49 changes: 49 additions & 0 deletions resources/plugin.rb
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 test/fixtures/cookbooks/sonarqube_plugin_consumer/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name 'sonarqube_plugin_consumer'
depends 'sonarqube'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sonarqube_plugin 'groovy' do
version '1.3'
end
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

0 comments on commit c7f3452

Please sign in to comment.