2020-11-24 15:15:51 +05:30
|
|
|
# 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'
|
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
modules: modules,
|
2020-11-24 15:15:51 +05:30
|
|
|
scopes: %w(READ WRITE DELETE),
|
|
|
|
apiVersion: 1,
|
|
|
|
apiMigrations: {
|
|
|
|
gdpr: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
HOME_URL = 'https://gitlab.com'
|
|
|
|
DOC_URL = 'https://docs.gitlab.com/ee/user/project/integrations/jira.html#gitlab-jira-integration'
|
|
|
|
|
|
|
|
def modules
|
|
|
|
modules = {
|
|
|
|
jiraDevelopmentTool: {
|
|
|
|
key: 'gitlab-development-tool',
|
|
|
|
application: {
|
|
|
|
value: 'GitLab'
|
|
|
|
},
|
|
|
|
name: {
|
|
|
|
value: 'GitLab'
|
|
|
|
},
|
|
|
|
url: HOME_URL,
|
|
|
|
logoUrl: logo_url,
|
|
|
|
capabilities: %w(branch commit pull_request)
|
|
|
|
},
|
|
|
|
postInstallPage: {
|
|
|
|
key: 'gitlab-configuration',
|
|
|
|
name: {
|
|
|
|
value: 'GitLab Configuration'
|
|
|
|
},
|
|
|
|
url: relative_to_base_path(jira_connect_subscriptions_path)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
modules.merge!(build_information_module)
|
|
|
|
|
|
|
|
modules
|
|
|
|
end
|
|
|
|
|
|
|
|
def logo_url
|
|
|
|
view_context.image_url('gitlab_logo.png')
|
|
|
|
end
|
|
|
|
|
|
|
|
# See: https://developer.atlassian.com/cloud/jira/software/modules/build/
|
|
|
|
def build_information_module
|
|
|
|
{
|
|
|
|
jiraBuildInfoProvider: {
|
|
|
|
homeUrl: HOME_URL,
|
|
|
|
logoUrl: logo_url,
|
|
|
|
documentationUrl: DOC_URL,
|
|
|
|
actions: {},
|
|
|
|
name: { value: "GitLab CI" },
|
|
|
|
key: "gitlab-ci"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
def relative_to_base_path(full_path)
|
|
|
|
full_path.sub(/^#{jira_connect_base_path}/, '')
|
|
|
|
end
|
|
|
|
end
|