Class: BambooService

Inherits:
CiService show all
Includes:
ReactiveService
Defined in:
app/models/project_services/bamboo_service.rb

Constant Summary

Constants inherited from Service

Service::DEV_SERVICE_NAMES, Service::SERVICE_NAMES

Instance Attribute Summary collapse

Attributes included from Importable

#imported, #importing

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CiService

supported_events, #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, #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, #supported_events, #supports_data_fields?, #test, #to_data_fields_hash, #to_param, #to_service_hash, #updated_properties

Methods included from ProjectServicesLoggable

#build_message, #log_error, #log_info, #logger

Methods inherited from ApplicationRecord

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

Instance Attribute Details

#responseObject

Returns the value of attribute response


17
18
19
# File 'app/models/project_services/bamboo_service.rb', line 17

def response
  @response
end

Class Method Details

.to_paramObject


45
46
47
# File 'app/models/project_services/bamboo_service.rb', line 45

def self.to_param
  'bamboo'
end

Instance Method Details

#build_page(sha, ref) ⇒ Object


61
62
63
# File 'app/models/project_services/bamboo_service.rb', line 61

def build_page(sha, ref)
  with_reactive_cache(sha, ref) {|cached| cached[:build_page] }
end

#calculate_reactive_cache(sha, ref) ⇒ Object


75
76
77
78
79
# File 'app/models/project_services/bamboo_service.rb', line 75

def calculate_reactive_cache(sha, ref)
  response = try_get_path("rest/api/latest/result/byChangeset/#{sha}")

  { build_page: read_build_page(response), commit_status: read_commit_status(response) }
end

#commit_status(sha, ref) ⇒ Object


65
66
67
# File 'app/models/project_services/bamboo_service.rb', line 65

def commit_status(sha, ref)
  with_reactive_cache(sha, ref) {|cached| cached[:commit_status] }
end

#compose_service_hookObject


22
23
24
25
# File 'app/models/project_services/bamboo_service.rb', line 22

def compose_service_hook
  hook = service_hook || build_service_hook
  hook.save
end

#descriptionObject


37
38
39
# File 'app/models/project_services/bamboo_service.rb', line 37

def description
  s_('BambooService|A continuous integration and build server')
end

#execute(data) ⇒ Object


69
70
71
72
73
# File 'app/models/project_services/bamboo_service.rb', line 69

def execute(data)
  return unless supported_events.include?(data[:object_kind])

  get_path("updateAndBuild.action", { buildKey: build_key })
end

#fieldsObject


49
50
51
52
53
54
55
56
57
58
59
# File 'app/models/project_services/bamboo_service.rb', line 49

def fields
  [
      { type: 'text', name: 'bamboo_url',
        placeholder: s_('BambooService|Bamboo root URL like https://bamboo.example.com'), required: true },
      { type: 'text', name: 'build_key',
        placeholder: s_('BambooService|Bamboo build plan key like KEY'), required: true },
      { type: 'text', name: 'username',
        placeholder: s_('BambooService|A user with API access, if applicable') },
      { type: 'password', name: 'password' }
  ]
end

#helpObject


41
42
43
# File 'app/models/project_services/bamboo_service.rb', line 41

def help
  s_('BambooService|You must set up automatic revision labeling and a repository trigger in Bamboo.')
end

#reset_passwordObject


27
28
29
30
31
# File 'app/models/project_services/bamboo_service.rb', line 27

def reset_password
  if bamboo_url_changed? && !password_touched?
    self.password = nil
  end
end

#titleObject


33
34
35
# File 'app/models/project_services/bamboo_service.rb', line 33

def title
  s_('BambooService|Atlassian Bamboo CI')
end