Skip to content
Snippets Groups Projects
Commit 40d3d574 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 5939b09f
No related branches found
No related tags found
No related merge requests found
Showing
with 109 additions and 35 deletions
Loading
Loading
@@ -10,6 +10,7 @@ module ServiceParams
:api_url,
:api_version,
:bamboo_url,
:branches_to_be_notified,
:build_key,
:build_type,
:ca_pem,
Loading
Loading
@@ -41,7 +42,6 @@ module ServiceParams
:new_issue_url,
:notify,
:notify_only_broken_pipelines,
:notify_only_default_branch,
:password,
:priority,
:project_key,
Loading
Loading
Loading
Loading
@@ -45,7 +45,11 @@ module Emails
private
 
def note_target_url_options
[@project || @group, @note.noteable, anchor: "note_#{@note.id}"]
[@project || @group, @note.noteable, note_target_url_query_params]
end
def note_target_url_query_params
{ anchor: "note_#{@note.id}" }
end
 
def note_thread_options(recipient_id, reason)
Loading
Loading
# frozen_string_literal: true
# Concern handling functionality around deciding whether to send notification
# for activities on a specified branch or not. Will be included in
# ChatNotificationService and PipelinesEmailService classes.
module NotificationBranchSelection
extend ActiveSupport::Concern
BRANCH_CHOICES = [
[_('All branches'), 'all'],
[_('Default branch'), 'default'],
[_('Protected branches'), 'protected'],
[_('Default branch and protected branches'), 'default_and_protected']
].freeze
def notify_for_branch?(data)
ref = if data[:ref]
Gitlab::Git.ref_name(data[:ref])
else
data.dig(:object_attributes, :ref)
end
is_default_branch = ref == project.default_branch
is_protected_branch = project.protected_branches.exists?(name: ref)
case branches_to_be_notified
when "all"
true
when "default"
is_default_branch
when "protected"
is_protected_branch
when "default_and_protected"
is_default_branch || is_protected_branch
else
false
end
end
end
Loading
Loading
@@ -1811,6 +1811,7 @@ class Project < ApplicationRecord
.append(key: 'CI_PROJECT_NAMESPACE', value: namespace.full_path)
.append(key: 'CI_PROJECT_URL', value: web_url)
.append(key: 'CI_PROJECT_VISIBILITY', value: visibility)
.append(key: 'CI_PROJECT_REPOSITORY_LANGUAGES', value: repository_languages.map(&:name).join(',').downcase)
.concat(pages_variables)
.concat(container_registry_variables)
.concat(auto_devops_variables)
Loading
Loading
Loading
Loading
@@ -4,6 +4,7 @@
# This class is not meant to be used directly, but only to inherit from.
class ChatNotificationService < Service
include ChatMessage
include NotificationBranchSelection
 
SUPPORTED_EVENTS = %w[
push issue confidential_issue merge_request note confidential_note
Loading
Loading
@@ -14,7 +15,7 @@ class ChatNotificationService < Service
 
default_value_for :category, 'chat'
 
prop_accessor :webhook, :username, :channel
prop_accessor :webhook, :username, :channel, :branches_to_be_notified
 
# Custom serialized properties initialization
prop_accessor(*SUPPORTED_EVENTS.map { |event| EVENT_CHANNEL[event] })
Loading
Loading
@@ -27,7 +28,16 @@ class ChatNotificationService < Service
if properties.nil?
self.properties = {}
self.notify_only_broken_pipelines = true
self.notify_only_default_branch = true
self.branches_to_be_notified = "default"
elsif !self.notify_only_default_branch.nil?
# In older versions, there was only a boolean property named
# `notify_only_default_branch`. Now we have a string property named
# `branches_to_be_notified`. Instead of doing a background migration, we
# opted to set a value for the new property based on the old one, if
# users hasn't specified one already. When users edit the service and
# selects a value for this new property, it will override everything.
self.branches_to_be_notified ||= notify_only_default_branch? ? "default" : "all"
end
end
 
Loading
Loading
@@ -52,7 +62,7 @@ class ChatNotificationService < Service
{ type: 'text', name: 'webhook', placeholder: "e.g. #{webhook_placeholder}", required: true },
{ type: 'text', name: 'username', placeholder: 'e.g. GitLab' },
{ type: 'checkbox', name: 'notify_only_broken_pipelines' },
{ type: 'checkbox', name: 'notify_only_default_branch' }
{ type: 'select', name: 'branches_to_be_notified', choices: BRANCH_CHOICES }
]
end
 
Loading
Loading
@@ -168,15 +178,8 @@ class ChatNotificationService < Service
def notify_for_ref?(data)
return true if data[:object_kind] == 'tag_push'
return true if data.dig(:object_attributes, :tag)
return true unless notify_only_default_branch?
 
ref = if data[:ref]
Gitlab::Git.ref_name(data[:ref])
else
data.dig(:object_attributes, :ref)
end
ref == project.default_branch
notify_for_branch?(data)
end
 
def notify_for_pipeline?(data)
Loading
Loading
Loading
Loading
@@ -42,7 +42,7 @@ class DiscordService < ChatNotificationService
[
{ type: "text", name: "webhook", placeholder: "e.g. https://discordapp.com/api/webhooks/…" },
{ type: "checkbox", name: "notify_only_broken_pipelines" },
{ type: "checkbox", name: "notify_only_default_branch" }
{ type: 'select', name: 'branches_to_be_notified', choices: BRANCH_CHOICES }
]
end
 
Loading
Loading
Loading
Loading
@@ -44,7 +44,7 @@ class HangoutsChatService < ChatNotificationService
[
{ type: 'text', name: 'webhook', placeholder: "e.g. #{webhook_placeholder}" },
{ type: 'checkbox', name: 'notify_only_broken_pipelines' },
{ type: 'checkbox', name: 'notify_only_default_branch' }
{ type: 'select', name: 'branches_to_be_notified', choices: BRANCH_CHOICES }
]
end
 
Loading
Loading
Loading
Loading
@@ -42,7 +42,7 @@ class MicrosoftTeamsService < ChatNotificationService
[
{ type: 'text', name: 'webhook', placeholder: "e.g. #{webhook_placeholder}" },
{ type: 'checkbox', name: 'notify_only_broken_pipelines' },
{ type: 'checkbox', name: 'notify_only_default_branch' }
{ type: 'select', name: 'branches_to_be_notified', choices: BRANCH_CHOICES }
]
end
 
Loading
Loading
# frozen_string_literal: true
 
class PipelinesEmailService < Service
prop_accessor :recipients
include NotificationBranchSelection
prop_accessor :recipients, :branches_to_be_notified
boolean_accessor :notify_only_broken_pipelines, :notify_only_default_branch
validates :recipients, presence: true, if: :valid_recipients?
 
def initialize_properties
self.properties ||= { notify_only_broken_pipelines: true, notify_only_default_branch: false }
if properties.nil?
self.properties = {}
self.notify_only_broken_pipelines = true
self.branches_to_be_notified = "default"
elsif !self.notify_only_default_branch.nil?
# In older versions, there was only a boolean property named
# `notify_only_default_branch`. Now we have a string property named
# `branches_to_be_notified`. Instead of doing a background migration, we
# opted to set a value for the new property based on the old one, if
# users hasn't specified one already. When users edit the service and
# selects a value for this new property, it will override everything.
self.branches_to_be_notified ||= notify_only_default_branch? ? "default" : "all"
end
end
 
def title
Loading
Loading
@@ -55,8 +70,9 @@ class PipelinesEmailService < Service
required: true },
{ type: 'checkbox',
name: 'notify_only_broken_pipelines' },
{ type: 'checkbox',
name: 'notify_only_default_branch' }
{ type: 'select',
name: 'branches_to_be_notified',
choices: BRANCH_CHOICES }
]
end
 
Loading
Loading
@@ -69,13 +85,7 @@ class PipelinesEmailService < Service
end
 
def should_pipeline_be_notified?(data)
notify_for_pipeline_branch?(data) && notify_for_pipeline?(data)
end
def notify_for_pipeline_branch?(data)
return true unless notify_only_default_branch?
data[:object_attributes][:ref] == data[:project][:default_branch]
notify_for_branch?(data) && notify_for_pipeline?(data)
end
 
def notify_for_pipeline?(data)
Loading
Loading
Loading
Loading
@@ -111,7 +111,7 @@
= nav_link(controller: :gpg_keys) do
= link_to profile_gpg_keys_path do
.nav-icon-container
= sprite_icon('key-modern')
= sprite_icon('key')
%span.nav-item-name
= _('GPG Keys')
%ul.sidebar-sub-level-items.is-fly-out-only
Loading
Loading
---
title: Support chat notifications to be fired for protected branches
merge_request: 32176
author:
type: added
Loading
Loading
@@ -6,9 +6,9 @@ class AddTargetProjectIdToMergeTrains < ActiveRecord::Migration[5.1]
DOWNTIME = false
 
def change
# rubocop: disable Rails/NotNullColumn
# rubocop:disable Rails/NotNullColumn, Migration/AddReference
add_reference :merge_trains, :target_project, null: false, index: true, foreign_key: { on_delete: :cascade, to_table: :projects }, type: :integer
add_column :merge_trains, :target_branch, :text, null: false
# rubocop: enable Rails/NotNullColumn
# rubocop:enable Rails/NotNullColumn, Migration/AddReference
end
end
Loading
Loading
@@ -4,7 +4,9 @@ class AddEnvironmentIdToClustersKubernetesNamespaces < ActiveRecord::Migration[5
DOWNTIME = false
 
def change
# rubocop:disable Migration/AddReference
add_reference :clusters_kubernetes_namespaces, :environment,
index: true, type: :bigint, foreign_key: { on_delete: :nullify }
# rubocop:enable Migration/AddReference
end
end
Loading
Loading
@@ -4,7 +4,9 @@ class AddIssueIdToVersions < ActiveRecord::Migration[5.2]
DOWNTIME = false
 
def up
# rubocop:disable Migration/AddReference
add_reference :design_management_versions, :issue, index: true, foreign_key: { on_delete: :cascade }
# rubocop:enable Migration/AddReference
end
 
def down
Loading
Loading
Loading
Loading
@@ -4,11 +4,13 @@ class AddColumnForSelfMonitoringProjectId < ActiveRecord::Migration[5.2]
DOWNTIME = false
 
def change
# rubocop:disable Migration/AddReference
add_reference(
:application_settings,
:instance_administration_project,
index: { name: 'index_applicationsettings_on_instance_administration_project_id' },
foreign_key: { to_table: :projects, on_delete: :nullify }
)
# rubocop:enable Migration/AddReference
end
end
Loading
Loading
@@ -436,7 +436,8 @@ Parameters:
| --------- | ---- | -------- | ----------- |
| `webhook` | string | true | The Hangouts Chat webhook. For example, `https://chat.googleapis.com/v1/spaces...`. |
| `notify_only_broken_pipelines` | boolean | false | Send notifications for broken pipelines |
| `notify_only_default_branch` | boolean | false | Send notifications only for the default branch |
| `notify_only_default_branch` | boolean | false | DEPRECATED: This parameter has been replaced with `branches_to_be_notified` |
| `branches_to_be_notified` | string | all | Branches to send notifications for. Valid options are "all", "default", "protected", and "default_and_protected" |
| `push_events` | boolean | false | Enable notifications for push events |
| `issues_events` | boolean | false | Enable notifications for issue events |
| `confidential_issues_events` | boolean | false | Enable notifications for confidential issue events |
Loading
Loading
@@ -745,7 +746,8 @@ Parameters:
| `recipients` | string | yes | Comma-separated list of recipient email addresses |
| `add_pusher` | boolean | no | Add pusher to recipients list |
| `notify_only_broken_pipelines` | boolean | no | Notify only broken pipelines |
| `notify_only_default_branch` | boolean | no | Send notifications only for the default branch ([introduced in GitLab 12.0](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/28271)) |
| `notify_only_default_branch` | boolean | no | DEPRECATED: This parameter has been replaced with `branches_to_be_notified` ([introduced in GitLab 12.0](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/28271)) |
| `branches_to_be_notified` | string | all | Branches to send notifications for. Valid options are "all", "default", "protected", and "default_and_protected" |
| `pipeline_events` | boolean | false | Enable notifications for pipeline events |
 
### Delete Pipeline-Emails service
Loading
Loading
@@ -933,7 +935,8 @@ Parameters:
| `username` | string | false | username |
| `channel` | string | false | Default channel to use if others are not configured |
| `notify_only_broken_pipelines` | boolean | false | Send notifications for broken pipelines |
| `notify_only_default_branch` | boolean | false | Send notifications only for the default branch |
| `notify_only_default_branch` | boolean | false | DEPRECATED: This parameter has been replaced with `branches_to_be_notified` |
| `branches_to_be_notified` | string | all | Branches to send notifications for. Valid options are "all", "default", "protected", and "default_and_protected" |
| `commit_events` | boolean | false | Enable notifications for commit events |
| `confidential_issue_channel` | string | false | The name of the channel to receive confidential issues events notifications |
| `confidential_issues_events` | boolean | false | Enable notifications for confidential issue events |
Loading
Loading
@@ -991,7 +994,8 @@ Parameters:
| --------- | ---- | -------- | ----------- |
| `webhook` | string | true | The Microsoft Teams webhook. For example, `https://outlook.office.com/webhook/...` |
| `notify_only_broken_pipelines` | boolean | false | Send notifications for broken pipelines |
| `notify_only_default_branch` | boolean | false | Send notifications only for the default branch |
| `notify_only_default_branch` | boolean | false | DEPRECATED: This parameter has been replaced with `branches_to_be_notified` |
| `branches_to_be_notified` | string | all | Branches to send notifications for. Valid options are "all", "default", "protected", and "default_and_protected" |
| `push_events` | boolean | false | Enable notifications for push events |
| `issues_events` | boolean | false | Enable notifications for issue events |
| `confidential_issues_events` | boolean | false | Enable notifications for confidential issue events |
Loading
Loading
@@ -1040,7 +1044,8 @@ Parameters:
| `username` | string | false | username |
| `channel` | string | false | Default channel to use if others are not configured |
| `notify_only_broken_pipelines` | boolean | false | Send notifications for broken pipelines |
| `notify_only_default_branch` | boolean | false | Send notifications only for the default branch |
| `notify_only_default_branch` | boolean | false | DEPRECATED: This parameter has been replaced with `branches_to_be_notified` |
| `branches_to_be_notified` | string | all | Branches to send notifications for. Valid options are "all", "default", "protected", and "default_and_protected" |
| `push_events` | boolean | false | Enable notifications for push events |
| `issues_events` | boolean | false | Enable notifications for issue events |
| `confidential_issues_events` | boolean | false | Enable notifications for confidential issue events |
Loading
Loading
Loading
Loading
@@ -88,6 +88,7 @@ future GitLab releases.**
| `CI_PROJECT_PATH_SLUG` | 9.3 | all | `$CI_PROJECT_PATH` lowercased and with everything except `0-9` and `a-z` replaced with `-`. Use in URLs and domain names. |
| `CI_PROJECT_URL` | 8.10 | 0.5 | The HTTP(S) address to access project |
| `CI_PROJECT_VISIBILITY` | 10.3 | all | The project visibility (internal, private, public) |
| `CI_PROJECT_REPOSITORY_LANGUAGES` | 12.3 | all | Comma-separated, lowercased list of the languages used in the repository (e.g. `ruby,javascript,html,css`) |
| `CI_COMMIT_REF_PROTECTED` | 11.11 | all | If the job is running on a protected branch |
| `CI_REGISTRY` | 8.10 | 0.5 | If the Container Registry is enabled it returns the address of GitLab's Container Registry |
| `CI_REGISTRY_IMAGE` | 8.10 | 0.5 | If the Container Registry is enabled for the project it returns the address of the registry tied to the specific project |
Loading
Loading
doc/user/project/integrations/img/hangouts_chat_configuration.png

43.6 KiB | W: 1290px | H: 937px

doc/user/project/integrations/img/hangouts_chat_configuration.png

69.5 KiB | W: 1143px | H: 941px

doc/user/project/integrations/img/hangouts_chat_configuration.png
doc/user/project/integrations/img/hangouts_chat_configuration.png
doc/user/project/integrations/img/hangouts_chat_configuration.png
doc/user/project/integrations/img/hangouts_chat_configuration.png
  • 2-up
  • Swipe
  • Onion skin
doc/user/project/integrations/img/mattermost_configuration.png

20 KiB | W: 608px | H: 947px

doc/user/project/integrations/img/mattermost_configuration.png

111 KiB | W: 1169px | H: 1369px

doc/user/project/integrations/img/mattermost_configuration.png
doc/user/project/integrations/img/mattermost_configuration.png
doc/user/project/integrations/img/mattermost_configuration.png
doc/user/project/integrations/img/mattermost_configuration.png
  • 2-up
  • Swipe
  • Onion skin
doc/user/project/integrations/img/microsoft_teams_configuration.png

94.2 KiB | W: 2458px | H: 1660px

doc/user/project/integrations/img/microsoft_teams_configuration.png

69.9 KiB | W: 1154px | H: 937px

doc/user/project/integrations/img/microsoft_teams_configuration.png
doc/user/project/integrations/img/microsoft_teams_configuration.png
doc/user/project/integrations/img/microsoft_teams_configuration.png
doc/user/project/integrations/img/microsoft_teams_configuration.png
  • 2-up
  • Swipe
  • Onion skin
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment