summaryrefslogtreecommitdiff
path: root/app/models/integrations
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 09:16:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 09:16:11 +0000
commitedaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch)
tree11f143effbfeba52329fb7afbd05e6e2a3790241 /app/models/integrations
parentd8a5691316400a0f7ec4f83832698f1988eb27c1 (diff)
downloadgitlab-ce-edaa33dee2ff2f7ea3fac488d41558eb5f86d68c.tar.gz
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'app/models/integrations')
-rw-r--r--app/models/integrations/base_chat_notification.rb8
-rw-r--r--app/models/integrations/datadog.rb47
-rw-r--r--app/models/integrations/jira.rb6
3 files changed, 48 insertions, 13 deletions
diff --git a/app/models/integrations/base_chat_notification.rb b/app/models/integrations/base_chat_notification.rb
index ca72de47d30..d0d54a92021 100644
--- a/app/models/integrations/base_chat_notification.rb
+++ b/app/models/integrations/base_chat_notification.rb
@@ -204,7 +204,7 @@ module Integrations
when "wiki_page"
Integrations::ChatMessage::WikiPageMessage.new(data)
when "deployment"
- Integrations::ChatMessage::DeploymentMessage.new(data)
+ Integrations::ChatMessage::DeploymentMessage.new(data) if notify_for_ref?(data)
end
end
@@ -241,7 +241,11 @@ module Integrations
def notify_for_ref?(data)
return true if data[:object_kind] == 'tag_push'
- return true if data.dig(:object_attributes, :tag)
+ return true if data[:object_kind] == 'deployment' && !Feature.enabled?(:chat_notification_deployment_protected_branch_filter, project)
+
+ ref = data[:ref] || data.dig(:object_attributes, :ref)
+ return true if ref.blank? # No need to check protected branches when there is no ref
+ return true if Gitlab::Git.tag_ref?(ref) # Skip protected branch check because it doesn't support tags
notify_for_branch?(data)
end
diff --git a/app/models/integrations/datadog.rb b/app/models/integrations/datadog.rb
index 72e0ca22ac2..b86f0aaa7ef 100644
--- a/app/models/integrations/datadog.rb
+++ b/app/models/integrations/datadog.rb
@@ -2,7 +2,6 @@
module Integrations
class Datadog < Integration
- include ActionView::Helpers::UrlHelper
include HasWebHook
extend Gitlab::Utils::Override
@@ -34,12 +33,21 @@ module Integrations
SUPPORTED_EVENTS
end
+ def supported_events
+ events = super
+
+ return events + ['archive_trace'] if Feature.enabled?(:datadog_integration_logs_collection, parent)
+
+ events
+ end
+
def self.default_test_event
'pipeline'
end
def configurable_events
[] # do not allow to opt out of required hooks
+ # archive_trace is opt-in but we handle it with a more detailed field below
end
def title
@@ -51,7 +59,11 @@ module Integrations
end
def help
- docs_link = link_to s_('DatadogIntegration|How do I set up this integration?'), Rails.application.routes.url_helpers.help_page_url('integration/datadog'), target: '_blank', rel: 'noopener noreferrer'
+ docs_link = ActionController::Base.helpers.link_to(
+ s_('DatadogIntegration|How do I set up this integration?'),
+ Rails.application.routes.url_helpers.help_page_url('integration/datadog'),
+ target: '_blank', rel: 'noopener noreferrer'
+ )
s_('DatadogIntegration|Send CI/CD pipeline information to Datadog to monitor for job failures and troubleshoot performance issues. %{docs_link}').html_safe % { docs_link: docs_link.html_safe }
end
@@ -60,7 +72,7 @@ module Integrations
end
def fields
- [
+ f = [
{
type: 'text',
name: 'datadog_site',
@@ -93,7 +105,21 @@ module Integrations
linkClose: '</a>'.html_safe
},
required: true
- },
+ }
+ ]
+
+ if Feature.enabled?(:datadog_integration_logs_collection, parent)
+ f.append({
+ type: 'checkbox',
+ name: 'archive_trace_events',
+ title: s_('Logs'),
+ checkbox_label: s_('Enable logs collection'),
+ help: s_('When enabled, job logs are collected by Datadog and displayed along with pipeline execution traces.'),
+ required: false
+ })
+ end
+
+ f += [
{
type: 'text',
name: 'datadog_service',
@@ -116,6 +142,8 @@ module Integrations
}
}
]
+
+ f
end
override :hook_url
@@ -136,8 +164,7 @@ module Integrations
object_kind = 'job' if object_kind == 'build'
return unless supported_events.include?(object_kind)
- data = data.with_retried_builds if data.respond_to?(:with_retried_builds)
-
+ data = hook_data(data, object_kind)
execute_web_hook!(data, "#{object_kind} hook")
end
@@ -158,5 +185,13 @@ module Integrations
# US3 needs to keep a prefix but other datacenters cannot have the listed "app" prefix
datadog_site.delete_prefix("app.")
end
+
+ def hook_data(data, object_kind)
+ if object_kind == 'pipeline' && data.respond_to?(:with_retried_builds)
+ return data.with_retried_builds
+ end
+
+ data
+ end
end
end
diff --git a/app/models/integrations/jira.rb b/app/models/integrations/jira.rb
index d46299de1be..816f5cbe177 100644
--- a/app/models/integrations/jira.rb
+++ b/app/models/integrations/jira.rb
@@ -303,11 +303,7 @@ module Integrations
private
def branch_name(commit)
- if Feature.enabled?(:jira_use_first_ref_by_oid, project, default_enabled: :yaml)
- commit.first_ref_by_oid(project.repository)
- else
- commit.ref_names(project.repository).first
- end
+ commit.first_ref_by_oid(project.repository)
end
def server_info