2020-09-01 08:11:01 -04:00
|
|
|
# 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
|
|
|
|
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', anchor: 'gitlabcom-1')
|
|
|
|
},
|
|
|
|
authentication: {
|
|
|
|
type: 'jwt'
|
|
|
|
},
|
2020-12-09 16:09:43 -05:00
|
|
|
modules: modules,
|
2020-09-01 08:11:01 -04:00
|
|
|
scopes: %w(READ WRITE DELETE),
|
|
|
|
apiVersion: 1,
|
|
|
|
apiMigrations: {
|
2021-06-01 17:10:06 -04:00
|
|
|
'context-qsh': true,
|
2021-11-03 14:13:40 -04:00
|
|
|
'signed-install': true,
|
2020-09-01 08:11:01 -04:00
|
|
|
gdpr: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-12-09 16:09:43 -05:00
|
|
|
HOME_URL = 'https://gitlab.com'
|
2021-05-19 05:10:19 -04:00
|
|
|
DOC_URL = 'https://docs.gitlab.com/ee/integration/jira/'
|
2020-12-09 16:09:43 -05:00
|
|
|
|
|
|
|
def modules
|
|
|
|
modules = {
|
|
|
|
postInstallPage: {
|
|
|
|
key: 'gitlab-configuration',
|
2021-07-23 08:09:05 -04:00
|
|
|
name: { value: 'GitLab Configuration' },
|
2021-08-31 17:10:43 -04:00
|
|
|
url: relative_to_base_path(jira_connect_subscriptions_path),
|
|
|
|
conditions: [
|
|
|
|
{
|
|
|
|
condition: 'user_is_admin',
|
|
|
|
invert: false
|
|
|
|
}
|
|
|
|
]
|
2020-12-09 16:09:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-23 08:09:05 -04:00
|
|
|
modules.merge!(development_tool_module)
|
2020-12-09 16:09:43 -05:00
|
|
|
modules.merge!(build_information_module)
|
2021-01-06 07:10:58 -05:00
|
|
|
modules.merge!(deployment_information_module)
|
2021-01-13 07:10:27 -05:00
|
|
|
modules.merge!(feature_flag_module)
|
2020-12-09 16:09:43 -05:00
|
|
|
|
|
|
|
modules
|
|
|
|
end
|
|
|
|
|
|
|
|
def logo_url
|
|
|
|
view_context.image_url('gitlab_logo.png')
|
|
|
|
end
|
|
|
|
|
2021-07-23 08:09:05 -04:00
|
|
|
# See https://developer.atlassian.com/cloud/jira/software/modules/development-tool/
|
|
|
|
def development_tool_module
|
|
|
|
{
|
|
|
|
jiraDevelopmentTool: {
|
2021-08-09 05:22:41 -04:00
|
|
|
actions: {
|
|
|
|
createBranch: {
|
|
|
|
templateUrl: new_jira_connect_branch_url + '?issue_key={issue.key}&issue_summary={issue.summary}'
|
|
|
|
}
|
|
|
|
},
|
2021-07-23 08:09:05 -04:00
|
|
|
key: 'gitlab-development-tool',
|
|
|
|
application: { value: 'GitLab' },
|
|
|
|
name: { value: 'GitLab' },
|
|
|
|
url: HOME_URL,
|
|
|
|
logoUrl: logo_url,
|
|
|
|
capabilities: %w(branch commit pull_request)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2021-01-06 07:10:58 -05:00
|
|
|
# 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
|
|
|
|
|
2021-01-13 07:10:27 -05:00
|
|
|
# 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
|
2021-07-23 08:09:05 -04:00
|
|
|
name: { value: 'GitLab Feature Flags' },
|
2021-01-13 07:10:27 -05:00
|
|
|
key: 'gitlab-feature-flags'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-12-09 16:09:43 -05:00
|
|
|
# See: https://developer.atlassian.com/cloud/jira/software/modules/build/
|
|
|
|
def build_information_module
|
|
|
|
{
|
2021-01-06 07:10:58 -05:00
|
|
|
jiraBuildInfoProvider: common_module_properties.merge(
|
2020-12-09 16:09:43 -05:00
|
|
|
actions: {},
|
|
|
|
name: { value: "GitLab CI" },
|
|
|
|
key: "gitlab-ci"
|
2021-01-06 07:10:58 -05:00
|
|
|
)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def common_module_properties
|
|
|
|
{
|
|
|
|
homeUrl: HOME_URL,
|
|
|
|
logoUrl: logo_url,
|
|
|
|
documentationUrl: DOC_URL
|
2020-12-09 16:09:43 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-09-01 08:11:01 -04:00
|
|
|
def relative_to_base_path(full_path)
|
|
|
|
full_path.sub(/^#{jira_connect_base_path}/, '')
|
|
|
|
end
|
|
|
|
end
|