diff --git a/manifests/init.pp b/manifests/init.pp index a6b3873..307c469 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -62,6 +62,34 @@ # Gerrit configuration options; see Gerrit docs. # commentlinks: # A list of regexes Gerrit should hyperlink. +# its_plugins: +# A list of its (issue tracking system) plugins to configure. +# Example: +# its_plugins => [ +# { +# 'name' => 'its-storyboard', +# 'password' => 'secret_token', +# 'url' => 'https://storyboard.openstack.org', +# }, +# ], +# +# its_rules: +# A list of actions to perform on the its. +# Example: +# its_rules => [ +# { +# 'name' => 'change_updates', +# 'event_type' => 'patchset-created', +# 'action' => 'add-standard-comment', +# label => [ +# { +# 'name' => 'approval-Code-Review', +# 'approvals' => '-2, -1', +# }, +# ] +# }, +# ] +# # trackingids: # A list of regexes to reference external tracking systems. # war: @@ -205,6 +233,8 @@ class gerrit( $httpd_maxqueued = '', $httpd_maxwait = '', $commentlinks = [], + $its_plugins = [], + $its_rules = [], $trackingids = [], $contactstore = false, $contactstore_appsec = '', @@ -397,6 +427,8 @@ class gerrit( # - $httpd_maxthreads # - $httpd_maxqueued # - $commentlinks + # - $its_plugins + # - $its_rules # - $trackingids # - $enable_melody # - $melody_session @@ -444,6 +476,23 @@ class gerrit( require => File['/home/gerrit2/review_site/etc'], } + # setup rules for its (issue tracking system) plugins + file { '/home/gerrit2/review_site/etc/its': + ensure => 'directory', + owner => 'gerrit2', + group => 'gerrit2', + mode => '0644', + require => File['/home/gerrit2/review_site/etc'], + } + file { '/home/gerrit2/review_site/etc/its/actions.config': + ensure => present, + owner => 'gerrit2', + group => 'gerrit2', + mode => '0644', + content => template('gerrit/gerrit.its_rules.erb'), + replace => true, + } + # Set up apache. # Template uses: diff --git a/spec/acceptance/fixtures/default.pp b/spec/acceptance/fixtures/default.pp index e57a9b9..7d5ba03 100644 --- a/spec/acceptance/fixtures/default.pp +++ b/spec/acceptance/fixtures/default.pp @@ -40,6 +40,26 @@ class { '::gerrit': longLinesThreshold => '20', rejectTooLong => 'true', }, + its_plugins => [ + { + 'name' => 'its-storyboard', + 'password' => 'secret_token', + 'url' => 'https://storyboard.openstack.org', + }, + ], + its_rules => [ + { + 'name' => 'change_updates', + 'event_type' => 'patchset-created', + 'action' => 'add-standard-comment', + label => [ + { + 'name' => 'approval-Code-Review', + 'approvals' => '-2, -1', + }, + ] + }, + ] } class { '::gerrit::cron': } diff --git a/templates/gerrit.config.erb b/templates/gerrit.config.erb index 3ac6b06..21a862c 100644 --- a/templates/gerrit.config.erb +++ b/templates/gerrit.config.erb @@ -141,6 +141,10 @@ html = "<%= commentlink['html'] %>" <% end -%> <% end -%> +<% @its_plugins.each do |its_plugin| -%> +[<%= its_plugin['name'] %>] + url = <%= its_plugin['url'] %> +<% end -%> <% @trackingids.each do |trackingid| -%> [trackingid "<%= trackingid['name'] %>"] match = "<%= trackingid['match'] %>" diff --git a/templates/gerrit.its_rules.erb b/templates/gerrit.its_rules.erb new file mode 100644 index 0000000..ec4e3e6 --- /dev/null +++ b/templates/gerrit.its_rules.erb @@ -0,0 +1,12 @@ +<% @its_rules.each do |its_rule| -%> +[rule "<%= its_rule['name'] %>"] + action = <%= its_rule['action'] %> + <% unless its_rule['event-type'].nil? -%> + event-type = <%= its_rule['event_type'] %> + <% end -%> + <% unless its_rule['label'].nil? -%> + <% its_rule['label'].each do |its_label| -%> + <%= its_label['name'] %> = <%= its_label['approvals'] %> + <% end -%> + <% end -%> +<% end -%> diff --git a/templates/secure.config.erb b/templates/secure.config.erb index d80536b..94b2760 100644 --- a/templates/secure.config.erb +++ b/templates/secure.config.erb @@ -3,3 +3,7 @@ [auth] registerEmailPrivateKey = <%= @email_private_key %> restTokenPrivateKey = <%= @token_private_key %> +<% @its_plugins.each do |its_plugin| -%> +[<%= its_plugin['name'] %>] + password = <%= its_plugin['password'] %> +<% end -%>