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

44 lines
1.1 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-01-29 00:20:46 +05:30
def execute(commits: nil, branches: nil, merge_requests: nil, update_sequence_id: nil)
2020-11-24 15:15:51 +05:30
JiraConnectInstallation.for_project(project).each do |installation|
client = Atlassian::JiraConnect::Client.new(installation.base_url, installation.shared_secret)
2021-01-29 00:20:46 +05:30
response = client.store_dev_info(project: project, commits: commits, branches: branches, merge_requests: merge_requests, update_sequence_id: update_sequence_id)
2020-11-24 15:15:51 +05:30
log_response(response)
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
}
if response && response['errorMessages']
logger.error(message)
else
logger.info(message)
end
end
def logger
Gitlab::ProjectServiceLogger
end
end
end