Class: IssueTrackerService
- Inherits:
-
Service
show all
- Defined in:
- app/models/project_services/issue_tracker_service.rb
Constant Summary
Constants inherited
from Service
Service::DEV_SERVICE_NAMES, Service::SERVICE_NAMES
Instance Attribute Summary
Attributes included from Importable
#imported, #importing
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Service
#activated?, #api_field_names, #async_execute, available_services_names, available_services_types, boolean_accessor, build_from_integration, #can_test?, #category, #configurable_event_actions, #configurable_events, default_integration, #description, dev_services_names, #editable?, #event_channel_names, event_description, #event_field, event_names, #event_names, find_or_create_templates, find_or_initialize_all, find_or_initialize_integration, #global_fields, #help, instance_exists_for?, #issue_tracker?, #json_fields, #operating?, prop_accessor, #reset_updated_properties, services_names, services_types, #show_active_box?, supported_event_actions, #supported_events, #test, #title, #to_data_fields_hash, #to_param, to_param, #to_service_hash, #updated_properties
#build_message, #log_error, #log_info, #logger
at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order
Class Method Details
.reference_pattern(only_long: false) ⇒ Object
Pattern used to extract links from comments Override this method on services that uses different patterns This pattern does not support cross-project references The other code assumes that this pattern is a superset of all overridden patterns. See ReferenceRegexes.external_pattern
20
21
22
23
24
25
26
|
# File 'app/models/project_services/issue_tracker_service.rb', line 20
def self.reference_pattern(only_long: false)
if only_long
/(\b[A-Z][A-Z0-9_]*-)#{Gitlab::Regex.issue}/
else
/(\b[A-Z][A-Z0-9_]*-|#{Issue.reference_prefix})#{Gitlab::Regex.issue}/
end
end
|
.supported_events ⇒ Object
98
99
100
|
# File 'app/models/project_services/issue_tracker_service.rb', line 98
def self.supported_events
%w(push)
end
|
Instance Method Details
#data_fields ⇒ Object
50
51
52
|
# File 'app/models/project_services/issue_tracker_service.rb', line 50
def data_fields
issue_tracker_data || self.build_issue_tracker_data
end
|
#default? ⇒ Boolean
54
55
56
|
# File 'app/models/project_services/issue_tracker_service.rb', line 54
def default?
default
end
|
#execute(data) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'app/models/project_services/issue_tracker_service.rb', line 102
def execute(data)
return unless supported_events.include?(data[:object_kind])
message = "#{self.type} was unable to reach #{self.project_url}. Check the url and try again."
result = false
begin
response = Gitlab::HTTP.head(self.project_url, verify: true)
if response
message = "#{self.type} received response #{response.code} when attempting to connect to #{self.project_url}"
result = true
end
rescue Gitlab::HTTP::Error, Timeout::Error, SocketError, Errno::ECONNRESET, Errno::ECONNREFUSED, OpenSSL::SSL::SSLError => error
message = "#{self.type} had an error when trying to connect to #{self.project_url}: #{error.message}"
end
log_info(message)
result
end
|
#fields ⇒ Object
74
75
76
77
78
79
80
|
# File 'app/models/project_services/issue_tracker_service.rb', line 74
def fields
[
{ type: 'text', name: 'project_url', placeholder: 'Project url', required: true },
{ type: 'text', name: 'issues_url', placeholder: 'Issue url', required: true },
{ type: 'text', name: 'new_issue_url', placeholder: 'New Issue url', required: true }
]
end
|
#handle_properties ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/models/project_services/issue_tracker_service.rb', line 28
def handle_properties
return unless properties
@legacy_properties_data = properties.dup
data_values = properties.slice!('title', 'description')
data_values.reject! { |key| data_fields.changed.include?(key) }
data_values.slice!(*data_fields.attributes.keys)
data_fields.assign_attributes(data_values) if data_values.present?
self.properties = {}
end
|
#initialize_properties ⇒ Object
82
83
84
|
# File 'app/models/project_services/issue_tracker_service.rb', line 82
def initialize_properties
{}
end
|
#issue_path(iid) ⇒ Object
70
71
72
|
# File 'app/models/project_services/issue_tracker_service.rb', line 70
def issue_path(iid)
issue_url(iid)
end
|
#issue_tracker_path ⇒ Object
62
63
64
|
# File 'app/models/project_services/issue_tracker_service.rb', line 62
def issue_tracker_path
project_url
end
|
#issue_url(iid) ⇒ Object
58
59
60
|
# File 'app/models/project_services/issue_tracker_service.rb', line 58
def issue_url(iid)
issues_url.gsub(':id', iid.to_s)
end
|
#legacy_properties_data ⇒ Object
42
43
44
|
# File 'app/models/project_services/issue_tracker_service.rb', line 42
def legacy_properties_data
@legacy_properties_data ||= {}
end
|
#new_issue_path ⇒ Object
66
67
68
|
# File 'app/models/project_services/issue_tracker_service.rb', line 66
def new_issue_path
new_issue_url
end
|
#set_default_data ⇒ Object
Initialize with default properties values
87
88
89
90
91
92
93
94
95
96
|
# File 'app/models/project_services/issue_tracker_service.rb', line 87
def set_default_data
return unless issues_tracker.present?
return if project_url || issues_url || new_issue_url
data_fields.project_url = issues_tracker['project_url']
data_fields.issues_url = issues_tracker['issues_url']
data_fields.new_issue_url = issues_tracker['new_issue_url']
end
|
#support_close_issue? ⇒ Boolean
122
123
124
|
# File 'app/models/project_services/issue_tracker_service.rb', line 122
def support_close_issue?
false
end
|
#support_cross_reference? ⇒ Boolean
126
127
128
|
# File 'app/models/project_services/issue_tracker_service.rb', line 126
def support_cross_reference?
false
end
|
#supports_data_fields? ⇒ Boolean
46
47
48
|
# File 'app/models/project_services/issue_tracker_service.rb', line 46
def supports_data_fields?
true
end
|