Class: Integrations::Teamcity

Inherits:
BaseCi show all
Includes:
EnableSslVerification, PushDataValidations, ReactivelyCached
Defined in:
app/models/integrations/teamcity.rb

Constant Summary collapse

TEAMCITY_SAAS_HOSTNAME =
/\A[^\.]+\.teamcity\.com\z/i

Constants inherited from Integration

Integration::BASE_CLASSES, Integration::DEV_INTEGRATION_NAMES, Integration::INTEGRATION_NAMES, Integration::PROJECT_SPECIFIC_INTEGRATION_NAMES, Integration::SECTION_TYPE_CONFIGURATION, Integration::SECTION_TYPE_CONNECTION, Integration::SECTION_TYPE_TRIGGER, Integration::SNOWPLOW_EVENT_ACTION, Integration::SNOWPLOW_EVENT_LABEL, Integration::UnknownType

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Instance Attribute Summary collapse

Attributes included from Importable

#imported, #importing

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PushDataValidations

#merge_request_valid?, #push_valid?, #tag_push_valid?

Methods included from EnableSslVerification

#fields, #initialize_properties

Methods inherited from BaseCi

#valid_token?

Methods inherited from Integration

#activate_disabled_reason, #activated?, #api_field_names, #async_execute, #attributes, available_integration_names, available_integration_types, boolean_accessor, build_from_integration, #category, #chat?, #ci?, #configurable_events, create_from_active_default_integrations, default_integration, #default_test_event, default_test_event, dev_integration_names, #dup, #editable?, #event_channel_names, event_description, event_names, #event_names, field, #fields, fields, find_or_initialize_all_non_project_specific, find_or_initialize_non_project_specific_integration, #form_fields, #group_level?, #inheritable?, inherited_descendants_from_self_or_ancestors_from, #initialize_properties, instance_exists_for?, #instance_level?, integration_name_to_model, integration_name_to_type, integration_names, #json_fields, #operating?, #parent, #project_level?, project_specific_integration_names, prop_accessor, #properties=, #reencrypt_properties, #reset_updated_properties, #secret_fields, #sections, #show_active_box?, #supported_events, #supports_data_fields?, #test, #testable?, #to_database_hash, #to_param, #updated_properties

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from ResetSecretFields

#exposing_secrets_fields

Methods included from Loggable

#build_message, #log_error, #log_exception, #log_info, #logger

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Instance Attribute Details

#responseObject

Returns the value of attribute response.



38
39
40
# File 'app/models/integrations/teamcity.rb', line 38

def response
  @response
end

Class Method Details

.supported_eventsObject



45
46
47
# File 'app/models/integrations/teamcity.rb', line 45

def supported_events
  %w[push merge_request]
end

.to_paramObject



41
42
43
# File 'app/models/integrations/teamcity.rb', line 41

def to_param
  'teamcity'
end

Instance Method Details

#build_page(sha, ref) ⇒ Object



62
63
64
# File 'app/models/integrations/teamcity.rb', line 62

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

#calculate_reactive_cache(sha, ref) ⇒ Object



70
71
72
73
74
75
76
77
78
# File 'app/models/integrations/teamcity.rb', line 70

def calculate_reactive_cache(sha, ref)
  response = get_path("httpAuth/app/rest/builds/branch:unspecified:any,revision:#{sha}")

  if response
    { build_page: read_build_page(response), commit_status: read_commit_status(response) }
  else
    { build_page: teamcity_url, commit_status: :error }
  end
end

#commit_status(sha, ref) ⇒ Object



66
67
68
# File 'app/models/integrations/teamcity.rb', line 66

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

#descriptionObject



54
55
56
# File 'app/models/integrations/teamcity.rb', line 54

def description
  s_('ProjectService|Run CI/CD pipelines with JetBrains TeamCity.')
end

#enable_ssl_verificationObject



89
90
91
92
# File 'app/models/integrations/teamcity.rb', line 89

def enable_ssl_verification
  original_value = Gitlab::Utils.to_boolean(properties['enable_ssl_verification'])
  original_value.nil? ? (new_record? || url_is_saas?) : original_value
end

#execute(data) ⇒ Object



80
81
82
83
84
85
86
87
# File 'app/models/integrations/teamcity.rb', line 80

def execute(data)
  case data[:object_kind]
  when 'push'
    execute_push(data)
  when 'merge_request'
    execute_merge_request(data)
  end
end

#helpObject



58
59
60
# File 'app/models/integrations/teamcity.rb', line 58

def help
  s_('To run CI/CD pipelines with JetBrains TeamCity, input the GitLab project details in the TeamCity project Version Control Settings.')
end

#titleObject



50
51
52
# File 'app/models/integrations/teamcity.rb', line 50

def title
  'JetBrains TeamCity'
end