debian-mirror-gitlab/app/services/jira_connect/sync_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.2 KiB
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
module JiraConnect
class SyncService
def initialize(project)
self.project = project
end
2021-02-22 17:27:13 +05:30
# Parameters: see Atlassian::JiraConnect::Client#send_info
# Includes: update_sequence_id, commits, branches, merge_requests, pipelines
def execute(**args)
JiraConnectInstallation.for_project(project).flat_map do |installation|
2020-11-24 15:15:51 +05:30
client = Atlassian::JiraConnect::Client.new(installation.base_url, installation.shared_secret)
2021-02-22 17:27:13 +05:30
responses = client.send_info(project: project, **args)
2020-11-24 15:15:51 +05:30
2021-02-22 17:27:13 +05:30
responses.each { |r| log_response(r) }
2020-11-24 15:15:51 +05:30
end
end
private
attr_accessor :project
def log_response(response)
message = {
message: 'response from jira dev_info api',
integration: 'JiraConnect',
project_id: project.id,
project_path: project.full_path,
jira_response: response&.to_json
}
2023-07-09 08:55:56 +05:30
has_errors = response && (response['errorMessage'].present? || response['errorMessages'].present?)
if has_errors
2020-11-24 15:15:51 +05:30
logger.error(message)
else
logger.info(message)
end
end
def logger
2022-07-16 23:28:13 +05:30
Gitlab::IntegrationsLogger
2020-11-24 15:15:51 +05:30
end
end
end