Class: BuildkiteService
Constant Summary
collapse
- ENDPOINT =
"https://buildkite.com"
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 CiService
#valid_token?
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, 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, #initialize_properties, 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, #supports_data_fields?, #test, #to_data_fields_hash, #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
.supported_events ⇒ Object
17
18
19
|
# File 'app/models/project_services/buildkite_service.rb', line 17
def self.supported_events
%w(push merge_request tag_push)
end
|
.to_param ⇒ Object
74
75
76
|
# File 'app/models/project_services/buildkite_service.rb', line 74
def self.to_param
'buildkite'
end
|
Instance Method Details
#build_page(sha, ref) ⇒ Object
62
63
64
|
# File 'app/models/project_services/buildkite_service.rb', line 62
def build_page(sha, ref)
"#{project_url}/builds?commit=#{sha}"
end
|
#calculate_reactive_cache(sha, ref) ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'app/models/project_services/buildkite_service.rb', line 94
def calculate_reactive_cache(sha, ref)
response = Gitlab::HTTP.try_get(commit_status_path(sha), request_options)
status =
if response&.code == 200 && response['status']
response['status']
else
:error
end
{ commit_status: status }
end
|
#commit_status(sha, ref) ⇒ Object
54
55
56
|
# File 'app/models/project_services/buildkite_service.rb', line 54
def commit_status(sha, ref)
with_reactive_cache(sha, ref) {|cached| cached[:commit_status] }
end
|
#commit_status_path(sha) ⇒ Object
58
59
60
|
# File 'app/models/project_services/buildkite_service.rb', line 58
def commit_status_path(sha)
"#{buildkite_endpoint('gitlab')}/status/#{status_token}.json?commit=#{sha}"
end
|
#compose_service_hook ⇒ Object
41
42
43
44
45
46
|
# File 'app/models/project_services/buildkite_service.rb', line 41
def compose_service_hook
hook = service_hook || build_service_hook
hook.url = webhook_url
hook.enable_ssl_verification = true
hook.save
end
|
#description ⇒ Object
70
71
72
|
# File 'app/models/project_services/buildkite_service.rb', line 70
def description
'Buildkite is a platform for running fast, secure, and scalable continuous integration pipelines on your own infrastructure'
end
|
#enable_ssl_verification ⇒ Object
24
25
26
|
# File 'app/models/project_services/buildkite_service.rb', line 24
def enable_ssl_verification
true
end
|
#enable_ssl_verification=(_value) ⇒ Object
Since SSL verification will always be enabled for Buildkite, we no longer needs to store the boolean. This is a stub method to work with deprecated API param. TODO: remove enable_ssl_verification after 14.0 gitlab.com/gitlab-org/gitlab/-/issues/222808
33
34
35
|
# File 'app/models/project_services/buildkite_service.rb', line 33
def enable_ssl_verification=(_value)
self.properties.delete('enable_ssl_verification') end
|
#execute(data) ⇒ Object
48
49
50
51
52
|
# File 'app/models/project_services/buildkite_service.rb', line 48
def execute(data)
return unless supported_events.include?(data[:object_kind])
service_hook.execute(data)
end
|
#fields ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'app/models/project_services/buildkite_service.rb', line 78
def fields
[
{ type: 'text',
name: 'token',
title: 'Integration Token',
help: 'This token will be provided when you create a Buildkite pipeline with a GitLab repository',
required: true },
{ type: 'text',
name: 'project_url',
title: 'Pipeline URL',
placeholder: "#{ENDPOINT}/acme-inc/test-pipeline",
required: true }
]
end
|
#title ⇒ Object
66
67
68
|
# File 'app/models/project_services/buildkite_service.rb', line 66
def title
'Buildkite'
end
|
#webhook_url ⇒ Object
37
38
39
|
# File 'app/models/project_services/buildkite_service.rb', line 37
def webhook_url
"#{buildkite_endpoint('webhook')}/deliver/#{webhook_token}"
end
|