diff options
Diffstat (limited to 'app/models/project_services/jira_service.rb')
-rw-r--r-- | app/models/project_services/jira_service.rb | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb index dafd3d095ec..5857d86f921 100644 --- a/app/models/project_services/jira_service.rb +++ b/app/models/project_services/jira_service.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +# Accessible as Project#external_issue_tracker class JiraService < IssueTrackerService extend ::Gitlab::Utils::Override include Gitlab::Routing @@ -30,7 +31,8 @@ class JiraService < IssueTrackerService # TODO: we can probably just delegate as part of # https://gitlab.com/gitlab-org/gitlab/issues/29404 - data_field :username, :password, :url, :api_url, :jira_issue_transition_id, :project_key, :issues_enabled, :vulnerabilities_enabled, :vulnerabilities_issuetype + data_field :username, :password, :url, :api_url, :jira_issue_transition_id, :project_key, :issues_enabled, + :vulnerabilities_enabled, :vulnerabilities_issuetype, :proxy_address, :proxy_port, :proxy_username, :proxy_password before_update :reset_password after_commit :update_deployment_type, on: [:create, :update], if: :update_deployment_type? @@ -157,11 +159,14 @@ class JiraService < IssueTrackerService # support any events. end - def find_issue(issue_key) - jira_request { client.Issue.find(issue_key) } + def find_issue(issue_key, rendered_fields: false) + options = {} + options = options.merge(expand: 'renderedFields') if rendered_fields + + jira_request { client.Issue.find(issue_key, options) } end - def close_issue(entity, external_issue) + def close_issue(entity, external_issue, current_user) issue = find_issue(external_issue.iid) return if issue.nil? || has_resolution?(issue) || !jira_issue_transition_id.present? @@ -178,6 +183,7 @@ class JiraService < IssueTrackerService # if it is closed, so we don't have one comment for every commit. issue = find_issue(issue.key) if transition_issue(issue) add_issue_solved_comment(issue, commit_id, commit_url) if has_resolution?(issue) + log_usage(:close_issue, current_user) end def create_cross_reference_note(mentioned, noteable, author) @@ -213,7 +219,7 @@ class JiraService < IssueTrackerService } } - add_comment(data, jira_issue) + add_comment(data, jira_issue).tap { log_usage(:cross_reference, author) } end def valid_connection? @@ -274,6 +280,12 @@ class JiraService < IssueTrackerService end end + def log_usage(action, user) + key = "i_ecosystem_jira_service_#{action}" + + Gitlab::UsageDataCounters::HLLRedisCounter.track_event(key, values: user.id) + end + def add_issue_solved_comment(issue, commit_id, commit_url) link_title = "Solved by commit #{commit_id}." comment = "Issue solved with [#{commit_id}|#{commit_url}]." |