From a0bfb0cb901835fd8a953992bcd2acd028120561 Mon Sep 17 00:00:00 2001 From: Palash Date: Thu, 17 Jan 2019 14:28:03 +0530 Subject: [PATCH] CD-3582: Add Support for Google Chat Notification Plugin --- README.md | 1 + .../extensions/job_attributes.rb | 23 ++++++++++++++++ .../extensions/publishers.rb | 26 +++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/README.md b/README.md index b7bbe41..b73cb59 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,7 @@ A number of the DSL options rely on Jenkins plugins, including: * ansicolor - "AnsiColor" * (view) type: 'categorizedView' - "categorized-view" * hipchat - "HipChat Plugin" +* google_chat - "google-chat-notification-plugin" * inject_env_vars - "Environment Injector Plugin" * priority - "Priority Sorter plugin" * downstream - "Parameterized Trigger plugin" diff --git a/lib/jenkins_pipeline_builder/extensions/job_attributes.rb b/lib/jenkins_pipeline_builder/extensions/job_attributes.rb index 5d30872..4042a70 100644 --- a/lib/jenkins_pipeline_builder/extensions/job_attributes.rb +++ b/lib/jenkins_pipeline_builder/extensions/job_attributes.rb @@ -265,6 +265,29 @@ end end +job_attribute do + name :google_chat + plugin_id 'google-chat-notification' + description 'This plugin allows your team to setup build notifications to be sent to Google Chat rooms.' + jenkins_name 'Google Chat Notification' + announced false + + xml path: '//properties' do |params| + send('io.cnaik.GoogleChatNotification', 'plugin' => 'google-chat-notification') do + url params[:url] || '' + notifyAborted params[:notifyAborted] || false + notifyFailure params[:notifyFailure] || false + notifyNotBuilt params[:notifyNotBuilt] || false + notifySuccess params[:notifySuccess] || false + notifyUnstable params[:notifyUnstable] || false + notifyBackToNormal params[:notifyBackToNormal] || false + suppressInfoLoggers params[:suppressInfoLoggers] || false + sameThreadNotification params[:sameThreadNotification] || false + message params[:message] || '' + end + end +end + job_attribute do name :hipchat plugin_id 'hipchat' diff --git a/lib/jenkins_pipeline_builder/extensions/publishers.rb b/lib/jenkins_pipeline_builder/extensions/publishers.rb index 6cd9c47..4ff6a5a 100644 --- a/lib/jenkins_pipeline_builder/extensions/publishers.rb +++ b/lib/jenkins_pipeline_builder/extensions/publishers.rb @@ -72,6 +72,32 @@ end end +publisher do + name :google_chat + plugin_id 'google-chat-notification' + description 'This plugin allows your team to setup build notifications to be sent to Google Chat rooms.' + jenkins_name 'Google Chat Notification' + announced false + + version '0' do + xml do |params| + params = {} if params == true + send('io.cnaik.GoogleChatNotification') do + url params[:url] || '' + message params[:message] || '' + notifyAborted params[:notifyAborted] || false + notifyFailure params[:notifyFailure] || false + notifyNotBuilt params[:notifyNotBuilt] || false + notifySuccess params[:notifySuccess] || false + notifyUnstable params[:notifyUnstable] || false + notifyBackToNormal params[:notifyBackToNormal] || false + suppressInfoLoggers params[:suppressInfoLoggers] || false + sameThreadNotification params[:sameThreadNotification] || false + end + end + end +end + publisher do name :hipchat plugin_id 'hipchat'