1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
# frozen_string_literal: true
# This returns an app descriptor for use with Jira in development mode
# For the Atlassian Marketplace, a static copy of this JSON is uploaded to the marketplace
# https://developer.atlassian.com/cloud/jira/platform/app-descriptor/
class JiraConnect::AppDescriptorController < JiraConnect::ApplicationController
HOME_URL = 'https://gitlab.com'
DOC_URL = 'https://docs.gitlab.com/ee/integration/jira/'
skip_before_action :verify_atlassian_jwt!
def show
render json: {
name: Atlassian::JiraConnect.app_name,
description: 'Integrate commits, branches and merge requests from GitLab into Jira',
key: Atlassian::JiraConnect.app_key,
baseUrl: jira_connect_base_url(protocol: 'https'),
lifecycle: {
installed: relative_to_base_path(jira_connect_events_installed_path),
uninstalled: relative_to_base_path(jira_connect_events_uninstalled_path)
},
vendor: {
name: 'GitLab',
url: 'https://gitlab.com'
},
links: {
documentation: help_page_url('integration/jira/development_panel.md')
},
authentication: {
type: 'jwt'
},
modules: modules,
scopes: %w[READ WRITE DELETE],
apiVersion: 1,
apiMigrations: {
'context-qsh': true,
'signed-install': true,
gdpr: true
}
}
end
private
def modules
modules = {
postInstallPage: {
key: 'gitlab-configuration',
name: { value: 'GitLab Configuration' },
url: relative_to_base_path(jira_connect_subscriptions_path),
conditions: [
{
condition: 'user_is_admin',
invert: false
}
]
}
}
modules.merge!(development_tool_module)
modules.merge!(build_information_module)
modules.merge!(deployment_information_module)
modules.merge!(feature_flag_module)
modules
end
def logo_url
view_context.image_url('gitlab_logo.png')
end
# See https://developer.atlassian.com/cloud/jira/software/modules/development-tool/
def development_tool_module
{
jiraDevelopmentTool: {
actions: actions,
key: 'gitlab-development-tool',
application: { value: 'GitLab' },
name: { value: 'GitLab' },
url: HOME_URL,
logoUrl: logo_url,
capabilities: %w[branch commit pull_request]
}
}
end
# See: https://developer.atlassian.com/cloud/jira/software/modules/deployment/
def deployment_information_module
{
jiraDeploymentInfoProvider: common_module_properties.merge(
actions: {}, # TODO: list deployments
name: { value: "GitLab Deployments" },
key: "gitlab-deployments"
)
}
end
# see: https://developer.atlassian.com/cloud/jira/software/modules/feature-flag/
def feature_flag_module
{
jiraFeatureFlagInfoProvider: common_module_properties.merge(
actions: {}, # TODO: create, link and list feature flags https://gitlab.com/gitlab-org/gitlab/-/issues/297386
name: { value: 'GitLab Feature Flags' },
key: 'gitlab-feature-flags'
)
}
end
# See: https://developer.atlassian.com/cloud/jira/software/modules/build/
def build_information_module
{
jiraBuildInfoProvider: common_module_properties.merge(
actions: {},
name: { value: "GitLab CI" },
key: "gitlab-ci"
)
}
end
def common_module_properties
{
homeUrl: HOME_URL,
logoUrl: logo_url,
documentationUrl: DOC_URL
}
end
def relative_to_base_path(full_path)
full_path.sub(/^#{jira_connect_base_path}/, '')
end
def create_branch_params
"?issue_key={issue.key}&issue_summary={issue.summary}&jwt={jwt}&addonkey=#{Atlassian::JiraConnect.app_key}"
end
def actions
{
createBranch: {
templateUrl: "#{route_jira_connect_branches_url}#{create_branch_params}"
},
searchConnectedWorkspaces: {
templateUrl: search_jira_connect_workspaces_url
},
searchRepositories: {
templateUrl: search_jira_connect_repositories_url
},
associateRepository: {
templateUrl: associate_jira_connect_repositories_url
}
}
end
end
|