diff --git a/murano-apps/Jenkins/package/Classes/Jenkins.yaml b/murano-apps/Jenkins/package/Classes/Jenkins.yaml index 12f7a18..27a3bbb 100644 --- a/murano-apps/Jenkins/package/Classes/Jenkins.yaml +++ b/murano-apps/Jenkins/package/Classes/Jenkins.yaml @@ -83,6 +83,7 @@ Methods: - $.gerrit.deploy() - $._environment.reporter.report($this, 'Creating jenkins account in gerrit...') - $.createGerritAccount() + - $.configureGerritPlugin($.gerrit) - $.configureUser() @@ -177,6 +178,23 @@ Methods: - $template: $resources.yaml('InstallGerritPlugin.template') - $.instance.agent.call($template, $resources) + configureGerritPlugin: + Arguments: + - gerrit: + Contract: $.class(opaas:Gerrit).notNull() + Body: + - If: $gerrit.instance.assignFloatingIp + Then: + - $host: $gerrit.instance.floatingIpAddress + Else: + - $host: $gerrit.instance.ipAddresses[0] + # Set gerrit related properties. + - $.instance.setHieraValue('gerrit_host', $host) + - $resources: new(sys:Resources) + - $._environment.reporter.report($this, 'Configure Jenkins Gerrit Trigger plugin...') + - $template: $resources.yaml('ConfigureGerritPlugin.template') + - $.instance.agent.call($template, $resources) + destroy: Body: - $.reportDestroyed() diff --git a/murano-apps/Jenkins/package/Resources/ConfigureGerritPlugin.template b/murano-apps/Jenkins/package/Resources/ConfigureGerritPlugin.template new file mode 100644 index 0000000..241f25b --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/ConfigureGerritPlugin.template @@ -0,0 +1,19 @@ +FormatVersion: 2.1.0 +Version: 1.0.0 +Name: Configure Gerrit Trigger Plugin + +Body: | + return configureGerritPlugin().stdout + +Scripts: + configureGerritPlugin: + Type: Application + Version: 1.0.0 + EntryPoint: configure_gerrit_plugin.sh + Files: + - configure_gerrit_plugin/templates/gerrit-trigger.xml.erb + - configure_gerrit_plugin/manifests/init.pp + - configure_gerrit_plugin.pp + Options: + captureStdout: true + captureStderr: true diff --git a/murano-apps/Jenkins/package/Resources/scripts/configure_gerrit_plugin.pp b/murano-apps/Jenkins/package/Resources/scripts/configure_gerrit_plugin.pp new file mode 100644 index 0000000..fda9c5e --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/configure_gerrit_plugin.pp @@ -0,0 +1,5 @@ +node default { + class { 'configure_gerrit_plugin': + gerrit_host => hiera('gerrit_host') + } +} diff --git a/murano-apps/Jenkins/package/Resources/scripts/configure_gerrit_plugin.sh b/murano-apps/Jenkins/package/Resources/scripts/configure_gerrit_plugin.sh new file mode 100644 index 0000000..6d097ec --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/configure_gerrit_plugin.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# No error if already exists. +mkdir -p /etc/puppet/modules/configure_gerrit_plugin +mkdir -p /etc/puppet/modules/configure_gerrit_plugin/manifests/ +mkdir -p /etc/puppet/modules/configure_gerrit_plugin/templates/ + +cp configure_gerrit_plugin/manifests/init.pp /etc/puppet/modules/configure_gerrit_plugin/manifests/ +cp configure_gerrit_plugin/templates/gerrit-trigger.xml.erb /etc/puppet/modules/configure_gerrit_plugin/templates/ + +puppet apply configure_gerrit_plugin.pp diff --git a/murano-apps/Jenkins/package/Resources/scripts/configure_gerrit_plugin/manifests/init.pp b/murano-apps/Jenkins/package/Resources/scripts/configure_gerrit_plugin/manifests/init.pp new file mode 100644 index 0000000..ce86aa2 --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/configure_gerrit_plugin/manifests/init.pp @@ -0,0 +1,16 @@ +class configure_gerrit_plugin ( + $gerrit_host = undef, +) { + service { 'jenkins': + ensure => running, + enable => true, + } + file { '/var/lib/jenkins/gerrit-trigger.xml': + notify => Service['jenkins'], + ensure => present, + owner => 'jenkins', + group => 'jenkins', + mode => '0644', + content => template('configure_gerrit_plugin/gerrit-trigger.xml.erb'), + } +} diff --git a/murano-apps/Jenkins/package/Resources/scripts/configure_gerrit_plugin/templates/gerrit-trigger.xml.erb b/murano-apps/Jenkins/package/Resources/scripts/configure_gerrit_plugin/templates/gerrit-trigger.xml.erb new file mode 100644 index 0000000..46c50ea --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/configure_gerrit_plugin/templates/gerrit-trigger.xml.erb @@ -0,0 +1,75 @@ + + + + + gerrit-server + false + + <%= @gerrit_host %> + 29418 + + jenkins + jenkins@mail.com + /var/lib/jenkins/.ssh/id_rsa + + false + false + false + gerrit review <CHANGE>,<PATCHSET> --message 'Build Successful <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> + gerrit review <CHANGE>,<PATCHSET> --message 'Build Unstable <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> + gerrit review <CHANGE>,<PATCHSET> --message 'Build Failed <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> + gerrit review <CHANGE>,<PATCHSET> --message 'Build Started <BUILDURL> <STARTED_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> + gerrit review <CHANGE>,<PATCHSET> --message 'No Builds Executed <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW> + http://<%= @gerrit_host %>:8081/ + 0 + 1 + -1 + 0 + 0 + 0 + 0 + 0 + -1 + 0 + true + true + 3 + 30 + true + 3600 + 0 + + + Code-Review + Code Review + + + Verified + Verified + + + + false + + false + + 0 + + + + + ALL + + false + false + false + + + + + + 3 + 1 + 360 + +