summaryrefslogtreecommitdiff
path: root/app/models/integrations
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 07:33:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 07:33:21 +0000
commit36a59d088eca61b834191dacea009677a96c052f (patch)
treee4f33972dab5d8ef79e3944a9f403035fceea43f /app/models/integrations
parenta1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff)
downloadgitlab-ce-36a59d088eca61b834191dacea009677a96c052f.tar.gz
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'app/models/integrations')
-rw-r--r--app/models/integrations/bamboo.rb54
-rw-r--r--app/models/integrations/base_chat_notification.rb4
-rw-r--r--app/models/integrations/base_ci.rb10
-rw-r--r--app/models/integrations/buildkite.rb31
-rw-r--r--app/models/integrations/drone_ci.rb32
-rw-r--r--app/models/integrations/field.rb1
-rw-r--r--app/models/integrations/jenkins.rb53
-rw-r--r--app/models/integrations/jira.rb41
-rw-r--r--app/models/integrations/mock_ci.rb18
-rw-r--r--app/models/integrations/packagist.rb3
-rw-r--r--app/models/integrations/prometheus.rb9
-rw-r--r--app/models/integrations/teamcity.rb46
12 files changed, 101 insertions, 201 deletions
diff --git a/app/models/integrations/bamboo.rb b/app/models/integrations/bamboo.rb
index b384a94d713..4e144a688f6 100644
--- a/app/models/integrations/bamboo.rb
+++ b/app/models/integrations/bamboo.rb
@@ -5,7 +5,26 @@ module Integrations
include ReactivelyCached
prepend EnableSslVerification
- prop_accessor :bamboo_url, :build_key, :username, :password
+ field :bamboo_url,
+ title: s_('BambooService|Bamboo URL'),
+ placeholder: s_('https://bamboo.example.com'),
+ help: s_('BambooService|Bamboo service root URL.'),
+ required: true
+
+ field :build_key,
+ help: s_('BambooService|Bamboo build plan key.'),
+ non_empty_password_title: s_('BambooService|Enter new build key'),
+ non_empty_password_help: s_('BambooService|Leave blank to use your current build key.'),
+ placeholder: s_('KEY'),
+ required: true
+
+ field :username,
+ help: s_('BambooService|The user with API access to the Bamboo server.')
+
+ field :password,
+ type: 'password',
+ non_empty_password_title: s_('ProjectService|Enter new password'),
+ non_empty_password_help: s_('ProjectService|Leave blank to use your current password')
validates :bamboo_url, presence: true, public_url: true, if: :activated?
validates :build_key, presence: true, if: :activated?
@@ -43,39 +62,6 @@ module Integrations
'bamboo'
end
- def fields
- [
- {
- type: 'text',
- name: 'bamboo_url',
- title: s_('BambooService|Bamboo URL'),
- placeholder: s_('https://bamboo.example.com'),
- help: s_('BambooService|Bamboo service root URL.'),
- required: true
- },
- {
- type: 'password',
- name: 'build_key',
- help: s_('BambooService|Bamboo build plan key.'),
- non_empty_password_title: s_('BambooService|Enter new build key'),
- non_empty_password_help: s_('BambooService|Leave blank to use your current build key.'),
- placeholder: s_('KEY'),
- required: true
- },
- {
- type: 'text',
- name: 'username',
- help: s_('BambooService|The user with API access to the Bamboo server.')
- },
- {
- type: 'password',
- name: 'password',
- non_empty_password_title: s_('ProjectService|Enter new password'),
- non_empty_password_help: s_('ProjectService|Leave blank to use your current password')
- }
- ]
- end
-
def build_page(sha, ref)
with_reactive_cache(sha, ref) {|cached| cached[:build_page] }
end
diff --git a/app/models/integrations/base_chat_notification.rb b/app/models/integrations/base_chat_notification.rb
index 54bd595892f..9bf208abcf7 100644
--- a/app/models/integrations/base_chat_notification.rb
+++ b/app/models/integrations/base_chat_notification.rb
@@ -149,6 +149,10 @@ module Integrations
raise NotImplementedError
end
+ def webhook_placeholder
+ raise NotImplementedError
+ end
+
private
def log_usage(_, _)
diff --git a/app/models/integrations/base_ci.rb b/app/models/integrations/base_ci.rb
index b2e269b1b50..4f8732da703 100644
--- a/app/models/integrations/base_ci.rb
+++ b/app/models/integrations/base_ci.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-# Base class for CI services
-# List methods you need to implement to get your CI service
+# Base class for CI integrations
+# List methods you need to implement to get your CI integration
# working with GitLab merge requests
module Integrations
class BaseCi < Integration
@@ -12,7 +12,7 @@ module Integrations
end
def self.supported_events
- %w(push)
+ %w[push]
end
# Return complete url to build page
@@ -30,10 +30,10 @@ module Integrations
#
#
# Ex.
- # @service.commit_status('13be4ac', 'master')
+ # @integration.commit_status('13be4ac', 'master')
# # => 'success'
#
- # @service.commit_status('2abe4ac', 'dev')
+ # @integration.commit_status('2abe4ac', 'dev')
# # => 'running'
#
#
diff --git a/app/models/integrations/buildkite.rb b/app/models/integrations/buildkite.rb
index 3b802271a36..d1e54ce86ee 100644
--- a/app/models/integrations/buildkite.rb
+++ b/app/models/integrations/buildkite.rb
@@ -10,7 +10,18 @@ module Integrations
ENDPOINT = "https://buildkite.com"
- prop_accessor :project_url, :token
+ field :project_url,
+ title: _('Pipeline URL'),
+ placeholder: "#{ENDPOINT}/example-org/test-pipeline",
+ required: true
+
+ field :token,
+ type: 'password',
+ title: _('Token'),
+ help: s_('ProjectService|The token you get after you create a Buildkite pipeline with a GitLab repository.'),
+ non_empty_password_title: s_('ProjectService|Enter new token'),
+ non_empty_password_help: s_('ProjectService|Leave blank to use your current token.'),
+ required: true
validates :project_url, presence: true, public_url: true, if: :activated?
validates :token, presence: true, if: :activated?
@@ -74,24 +85,6 @@ module Integrations
s_('ProjectService|Run CI/CD pipelines with Buildkite.')
end
- def fields
- [
- { type: 'password',
- name: 'token',
- title: _('Token'),
- help: s_('ProjectService|The token you get after you create a Buildkite pipeline with a GitLab repository.'),
- non_empty_password_title: s_('ProjectService|Enter new token'),
- non_empty_password_help: s_('ProjectService|Leave blank to use your current token.'),
- required: true },
-
- { type: 'text',
- name: 'project_url',
- title: _('Pipeline URL'),
- placeholder: "#{ENDPOINT}/example-org/test-pipeline",
- required: true }
- ]
- end
-
def calculate_reactive_cache(sha, ref)
response = Gitlab::HTTP.try_get(commit_status_path(sha), request_options)
diff --git a/app/models/integrations/drone_ci.rb b/app/models/integrations/drone_ci.rb
index 73f78bec381..0c65ed8cd5f 100644
--- a/app/models/integrations/drone_ci.rb
+++ b/app/models/integrations/drone_ci.rb
@@ -10,7 +10,17 @@ module Integrations
DRONE_SAAS_HOSTNAME = 'cloud.drone.io'
- prop_accessor :drone_url, :token
+ field :drone_url,
+ title: s_('ProjectService|Drone server URL'),
+ placeholder: 'http://drone.example.com',
+ required: true
+
+ field :token,
+ type: 'password',
+ help: s_('ProjectService|Token for the Drone project.'),
+ non_empty_password_title: s_('ProjectService|Enter new token'),
+ non_empty_password_help: s_('ProjectService|Leave blank to use your current token.'),
+ required: true
validates :drone_url, presence: true, public_url: true, if: :activated?
validates :token, presence: true, if: :activated?
@@ -94,26 +104,6 @@ module Integrations
s_('ProjectService|Run CI/CD pipelines with Drone.')
end
- def fields
- [
- {
- type: 'password',
- name: 'token',
- help: s_('ProjectService|Token for the Drone project.'),
- non_empty_password_title: s_('ProjectService|Enter new token'),
- non_empty_password_help: s_('ProjectService|Leave blank to use your current token.'),
- required: true
- },
- {
- type: 'text',
- name: 'drone_url',
- title: s_('ProjectService|Drone server URL'),
- placeholder: 'http://drone.example.com',
- required: true
- }
- ]
- end
-
override :hook_url
def hook_url
[drone_url, "/hook", "?owner=#{project.namespace.full_path}", "&name=#{project.path}", "&access_token=#{token}"].join
diff --git a/app/models/integrations/field.rb b/app/models/integrations/field.rb
index f00c4236a92..ca7833c1a56 100644
--- a/app/models/integrations/field.rb
+++ b/app/models/integrations/field.rb
@@ -10,6 +10,7 @@ module Integrations
non_empty_password_help
non_empty_password_title
api_only
+ exposes_secrets
].freeze
attr_reader :name
diff --git a/app/models/integrations/jenkins.rb b/app/models/integrations/jenkins.rb
index 32f11ee23eb..a1abbce72bc 100644
--- a/app/models/integrations/jenkins.rb
+++ b/app/models/integrations/jenkins.rb
@@ -7,7 +7,25 @@ module Integrations
prepend EnableSslVerification
extend Gitlab::Utils::Override
- prop_accessor :jenkins_url, :project_name, :username, :password
+ field :jenkins_url,
+ title: s_('ProjectService|Jenkins server URL'),
+ required: true,
+ placeholder: 'http://jenkins.example.com',
+ help: s_('The URL of the Jenkins server.')
+
+ field :project_name,
+ required: true,
+ placeholder: 'my_project_name',
+ help: s_('The name of the Jenkins project. Copy the name from the end of the URL to the project.')
+
+ field :username,
+ help: s_('The username for the Jenkins server.')
+
+ field :password,
+ type: 'password',
+ help: s_('The password for the Jenkins server.'),
+ non_empty_password_title: s_('ProjectService|Enter new password.'),
+ non_empty_password_help: s_('ProjectService|Leave blank to use your current password.')
before_validation :reset_password
@@ -15,7 +33,6 @@ module Integrations
validates :project_name, presence: true, if: :activated?
validates :username, presence: true, if: ->(service) { service.activated? && service.password_touched? && service.password.present? }
- default_value_for :push_events, true
default_value_for :merge_requests_events, false
default_value_for :tag_push_events, false
@@ -72,37 +89,5 @@ module Integrations
def self.to_param
'jenkins'
end
-
- def fields
- [
- {
- type: 'text',
- name: 'jenkins_url',
- title: s_('ProjectService|Jenkins server URL'),
- required: true,
- placeholder: 'http://jenkins.example.com',
- help: s_('The URL of the Jenkins server.')
- },
- {
- type: 'text',
- name: 'project_name',
- required: true,
- placeholder: 'my_project_name',
- help: s_('The name of the Jenkins project. Copy the name from the end of the URL to the project.')
- },
- {
- type: 'text',
- name: 'username',
- help: s_('The username for the Jenkins server.')
- },
- {
- type: 'password',
- name: 'password',
- help: s_('The password for the Jenkins server.'),
- non_empty_password_title: s_('ProjectService|Enter new password.'),
- non_empty_password_help: s_('ProjectService|Leave blank to use your current password.')
- }
- ]
- end
end
end
diff --git a/app/models/integrations/jira.rb b/app/models/integrations/jira.rb
index a800b9e5baa..992bd01bf5f 100644
--- a/app/models/integrations/jira.rb
+++ b/app/models/integrations/jira.rb
@@ -31,7 +31,6 @@ module Integrations
# We should use username/password for Jira Server and email/api_token for Jira Cloud,
# for more information check: https://gitlab.com/gitlab-org/gitlab-foss/issues/49936.
- before_validation :reset_password
after_commit :update_deployment_type, on: [:create, :update], if: :update_deployment_type?
enum comment_detail: {
@@ -46,12 +45,14 @@ module Integrations
required: true,
title: -> { s_('JiraService|Web URL') },
help: -> { s_('JiraService|Base URL of the Jira instance.') },
- placeholder: 'https://jira.example.com'
+ placeholder: 'https://jira.example.com',
+ exposes_secrets: true
field :api_url,
section: SECTION_TYPE_CONNECTION,
title: -> { s_('JiraService|Jira API URL') },
- help: -> { s_('JiraService|If different from Web URL.') }
+ help: -> { s_('JiraService|If different from Web URL.') },
+ exposes_secrets: true
field :username,
section: SECTION_TYPE_CONNECTION,
@@ -98,13 +99,6 @@ module Integrations
jira_tracker_data || self.build_jira_tracker_data
end
- def reset_password
- return unless reset_password?
-
- data_fields.password = nil
- self.properties = properties.except('password')
- end
-
def set_default_data
return unless issues_tracker.present?
@@ -174,7 +168,8 @@ module Integrations
sections.push({
type: SECTION_TYPE_JIRA_ISSUES,
title: _('Issues'),
- description: jira_issues_section_description
+ description: jira_issues_section_description,
+ plan: 'premium'
})
end
@@ -358,16 +353,7 @@ module Integrations
true
rescue StandardError => error
- log_error(
- "Issue transition failed",
- error: {
- exception_class: error.class.name,
- exception_message: error.message,
- exception_backtrace: Gitlab::BacktraceCleaner.clean_backtrace(error.backtrace)
- },
- client_url: client_url
- )
-
+ log_exception(error, message: 'Issue transition failed', client_url: client_url)
false
end
@@ -544,9 +530,7 @@ module Integrations
yield
rescue StandardError => error
@error = error
- payload = { client_url: client_url }
- Gitlab::ExceptionLogFormatter.format!(error, payload)
- log_error("Error sending message", payload)
+ log_exception(error, message: 'Error sending message', client_url: client_url)
nil
end
@@ -554,15 +538,6 @@ module Integrations
api_url.presence || url
end
- def reset_password?
- # don't reset the password if a new one is provided
- return false if password_touched?
- return true if api_url_changed?
- return false if api_url.present?
-
- url_changed?
- end
-
def update_deployment_type?
api_url_changed? || url_changed? || username_changed? || password_changed?
end
diff --git a/app/models/integrations/mock_ci.rb b/app/models/integrations/mock_ci.rb
index 568fb609a44..cd2928136ef 100644
--- a/app/models/integrations/mock_ci.rb
+++ b/app/models/integrations/mock_ci.rb
@@ -7,7 +7,11 @@ module Integrations
ALLOWED_STATES = %w[failed canceled running pending success success-with-warnings skipped not_found].freeze
- prop_accessor :mock_service_url
+ field :mock_service_url,
+ title: s_('ProjectService|Mock service URL'),
+ placeholder: 'http://localhost:4004',
+ required: true
+
validates :mock_service_url, presence: true, public_url: true, if: :activated?
def title
@@ -22,18 +26,6 @@ module Integrations
'mock_ci'
end
- def fields
- [
- {
- type: 'text',
- name: 'mock_service_url',
- title: s_('ProjectService|Mock service URL'),
- placeholder: 'http://localhost:4004',
- required: true
- }
- ]
- end
-
# Return complete url to build page
#
# Ex.
diff --git a/app/models/integrations/packagist.rb b/app/models/integrations/packagist.rb
index 738319ce835..758c9e4761b 100644
--- a/app/models/integrations/packagist.rb
+++ b/app/models/integrations/packagist.rb
@@ -10,9 +10,6 @@ module Integrations
validates :username, presence: true, if: :activated?
validates :token, presence: true, if: :activated?
- default_value_for :push_events, true
- default_value_for :tag_push_events, true
-
def title
'Packagist'
end
diff --git a/app/models/integrations/prometheus.rb b/app/models/integrations/prometheus.rb
index d6aafe45ae9..427034edb79 100644
--- a/app/models/integrations/prometheus.rb
+++ b/app/models/integrations/prometheus.rb
@@ -27,10 +27,7 @@ module Integrations
after_commit :track_events
- after_create_commit :create_default_alerts
-
scope :preload_project, -> { preload(:project) }
- scope :with_clusters_with_cilium, -> { joins(project: [:clusters]).merge(Clusters::Cluster.with_available_cilium) }
def show_active_box?
false
@@ -169,12 +166,6 @@ module Integrations
manual_configuration_changed? && !manual_configuration?
end
- def create_default_alerts
- return unless project_id
-
- ::Prometheus::CreateDefaultAlertsWorker.perform_async(project_id)
- end
-
def behind_iap?
manual_configuration? && google_iap_audience_client_id.present? && google_iap_service_account_json.present?
end
diff --git a/app/models/integrations/teamcity.rb b/app/models/integrations/teamcity.rb
index f0f83f118d7..1205173e40b 100644
--- a/app/models/integrations/teamcity.rb
+++ b/app/models/integrations/teamcity.rb
@@ -8,7 +8,22 @@ module Integrations
TEAMCITY_SAAS_HOSTNAME = /\A[^\.]+\.teamcity\.com\z/i.freeze
- prop_accessor :teamcity_url, :build_type, :username, :password
+ field :teamcity_url,
+ title: s_('ProjectService|TeamCity server URL'),
+ placeholder: 'https://teamcity.example.com',
+ required: true
+
+ field :build_type,
+ help: s_('ProjectService|The build configuration ID of the TeamCity project.'),
+ required: true
+
+ field :username,
+ help: s_('ProjectService|Must have permission to trigger a manual build in TeamCity.')
+
+ field :password,
+ type: 'password',
+ non_empty_password_title: s_('ProjectService|Enter new password'),
+ non_empty_password_help: s_('ProjectService|Leave blank to use your current password')
validates :teamcity_url, presence: true, public_url: true, if: :activated?
validates :build_type, presence: true, if: :activated?
@@ -51,35 +66,6 @@ module Integrations
s_('To run CI/CD pipelines with JetBrains TeamCity, input the GitLab project details in the TeamCity project Version Control Settings.')
end
- def fields
- [
- {
- type: 'text',
- name: 'teamcity_url',
- title: s_('ProjectService|TeamCity server URL'),
- placeholder: 'https://teamcity.example.com',
- required: true
- },
- {
- type: 'text',
- name: 'build_type',
- help: s_('ProjectService|The build configuration ID of the TeamCity project.'),
- required: true
- },
- {
- type: 'text',
- name: 'username',
- help: s_('ProjectService|Must have permission to trigger a manual build in TeamCity.')
- },
- {
- type: 'password',
- name: 'password',
- non_empty_password_title: s_('ProjectService|Enter new password'),
- non_empty_password_help: s_('ProjectService|Leave blank to use your current password')
- }
- ]
- end
-
def build_page(sha, ref)
with_reactive_cache(sha, ref) {|cached| cached[:build_page] }
end