diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 20:02:30 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 20:02:30 +0000 |
commit | 41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch) | |
tree | 9c8d89a8624828992f06d892cd2f43818ff5dcc8 /lib/atlassian | |
parent | 0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff) | |
download | gitlab-ce-41fe97390ceddf945f3d967b8fdb3de4c66b7dea.tar.gz |
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'lib/atlassian')
-rw-r--r-- | lib/atlassian/jira_connect.rb | 5 | ||||
-rw-r--r-- | lib/atlassian/jira_connect/client.rb | 23 | ||||
-rw-r--r-- | lib/atlassian/jira_connect/serializers/build_entity.rb | 2 | ||||
-rw-r--r-- | lib/atlassian/jira_connect/serializers/environment_entity.rb | 13 |
4 files changed, 20 insertions, 23 deletions
diff --git a/lib/atlassian/jira_connect.rb b/lib/atlassian/jira_connect.rb index 7f693eff59b..595cf0ac465 100644 --- a/lib/atlassian/jira_connect.rb +++ b/lib/atlassian/jira_connect.rb @@ -8,7 +8,10 @@ module Atlassian end def app_key - "gitlab-jira-connect-#{gitlab_host}" + # App key must be <= 64 characters. + # See: https://developer.atlassian.com/cloud/jira/platform/connect-app-descriptor/#app-descriptor-structure + + "gitlab-jira-connect-#{gitlab_host}"[..63] end private diff --git a/lib/atlassian/jira_connect/client.rb b/lib/atlassian/jira_connect/client.rb index dc37465744b..b8aa2cc8ea0 100644 --- a/lib/atlassian/jira_connect/client.rb +++ b/lib/atlassian/jira_connect/client.rb @@ -127,16 +127,21 @@ module Atlassian def handle_response(response, name, &block) data = response.parsed_response - case response.code - when 200 then yield data - when 400 then { 'errorMessages' => data.map { |e| e['message'] } } - when 401 then { 'errorMessages' => ['Invalid JWT'] } - when 403 then { 'errorMessages' => ["App does not support #{name}"] } - when 413 then { 'errorMessages' => ['Data too large'] + data.map { |e| e['message'] } } - when 429 then { 'errorMessages' => ['Rate limit exceeded'] } - when 503 then { 'errorMessages' => ['Service unavailable'] } + if [200, 202].include?(response.code) + yield data else - { 'errorMessages' => ['Unknown error'], 'response' => data } + message = case response.code + when 400 then { 'errorMessages' => data.map { |e| e['message'] } } + when 401 then { 'errorMessages' => ['Invalid JWT'] } + when 403 then { 'errorMessages' => ["App does not support #{name}"] } + when 413 then { 'errorMessages' => ['Data too large'] + data.map { |e| e['message'] } } + when 429 then { 'errorMessages' => ['Rate limit exceeded'] } + when 503 then { 'errorMessages' => ['Service unavailable'] } + else + { 'errorMessages' => ['Unknown error'], 'response' => data } + end + + message.merge('responseCode' => response.code) end end diff --git a/lib/atlassian/jira_connect/serializers/build_entity.rb b/lib/atlassian/jira_connect/serializers/build_entity.rb index a3434c529a4..10e4bb0e709 100644 --- a/lib/atlassian/jira_connect/serializers/build_entity.rb +++ b/lib/atlassian/jira_connect/serializers/build_entity.rb @@ -26,7 +26,7 @@ module Atlassian # merge request title. @issue_keys ||= begin pipeline.all_merge_requests.flat_map do |mr| - src = "#{mr.source_branch} #{mr.title}" + src = "#{mr.source_branch} #{mr.title} #{mr.description}" JiraIssueKeyExtractor.new(src).issue_keys end.uniq end diff --git a/lib/atlassian/jira_connect/serializers/environment_entity.rb b/lib/atlassian/jira_connect/serializers/environment_entity.rb index b6b5db40ba6..67ac93473c3 100644 --- a/lib/atlassian/jira_connect/serializers/environment_entity.rb +++ b/lib/atlassian/jira_connect/serializers/environment_entity.rb @@ -20,18 +20,7 @@ module Atlassian end def type - case environment.name - when /\A(.*[^a-z0-9])?(staging|stage|stg|preprod|pre-prod|model|internal)([^a-z0-9].*)?\z/i - 'staging' - when /\A(.*[^a-z0-9])?(prod|production|prd|live)([^a-z0-9].*)?\z/i - 'production' - when /\A(.*[^a-z0-9])?(test|testing|tests|tst|integration|integ|intg|int|acceptance|accept|acpt|qa|qc|control|quality)([^a-z0-9].*)?\z/i - 'testing' - when /\A(.*[^a-z0-9])?(dev|review|development)([^a-z0-9].*)?\z/i - 'development' - else - 'unmapped' - end + environment.tier == 'other' ? 'unmapped' : environment.tier end end end |