debian-mirror-gitlab/lib/api/helpers/integrations_helpers.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

930 lines
27 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
module API
module Helpers
2021-11-18 22:05:49 +05:30
# Helpers module for API::Integrations
2019-07-07 11:18:12 +05:30
#
# The data structures inside this model are returned using class methods,
# allowing EE to extend them where necessary.
2021-09-30 23:02:18 +05:30
module IntegrationsHelpers
2019-07-07 11:18:12 +05:30
def self.chat_notification_settings
[
{
required: true,
name: :webhook,
type: String,
desc: 'The chat webhook'
},
{
required: false,
name: :username,
type: String,
desc: 'The chat username'
},
{
required: false,
name: :channel,
type: String,
desc: 'The default chat channel'
2019-12-04 20:38:33 +05:30
},
{
required: false,
name: :branches_to_be_notified,
type: String,
desc: 'Branches for which notifications are to be sent'
2019-07-07 11:18:12 +05:30
}
].freeze
end
def self.chat_notification_flags
[
{
required: false,
name: :notify_only_broken_pipelines,
type: Boolean,
desc: 'Send notifications for broken pipelines'
}
].freeze
end
def self.chat_notification_channels
[
{
required: false,
name: :push_channel,
type: String,
desc: 'The name of the channel to receive push_events notifications'
},
{
required: false,
name: :issue_channel,
type: String,
desc: 'The name of the channel to receive issues_events notifications'
},
{
required: false,
name: :confidential_issue_channel,
type: String,
desc: 'The name of the channel to receive confidential_issues_events notifications'
},
{
required: false,
name: :merge_request_channel,
type: String,
desc: 'The name of the channel to receive merge_requests_events notifications'
},
{
required: false,
name: :note_channel,
type: String,
desc: 'The name of the channel to receive note_events notifications'
},
{
required: false,
name: :tag_push_channel,
type: String,
desc: 'The name of the channel to receive tag_push_events notifications'
},
{
required: false,
name: :pipeline_channel,
type: String,
desc: 'The name of the channel to receive pipeline_events notifications'
},
{
required: false,
name: :wiki_page_channel,
type: String,
desc: 'The name of the channel to receive wiki_page_events notifications'
}
].freeze
end
def self.chat_notification_events
[
{
required: false,
name: :push_events,
type: Boolean,
desc: 'Enable notifications for push_events'
},
{
required: false,
name: :issues_events,
type: Boolean,
desc: 'Enable notifications for issues_events'
},
{
required: false,
name: :confidential_issues_events,
type: Boolean,
desc: 'Enable notifications for confidential_issues_events'
},
{
required: false,
name: :merge_requests_events,
type: Boolean,
desc: 'Enable notifications for merge_requests_events'
},
{
required: false,
name: :note_events,
type: Boolean,
desc: 'Enable notifications for note_events'
},
2020-01-01 13:55:28 +05:30
{
required: false,
name: :confidential_note_events,
type: Boolean,
desc: 'Enable notifications for confidential_note_events'
},
2019-07-07 11:18:12 +05:30
{
required: false,
name: :tag_push_events,
type: Boolean,
desc: 'Enable notifications for tag_push_events'
},
{
required: false,
name: :pipeline_events,
type: Boolean,
desc: 'Enable notifications for pipeline_events'
},
{
required: false,
name: :wiki_page_events,
type: Boolean,
desc: 'Enable notifications for wiki_page_events'
}
].freeze
end
2021-09-30 23:02:18 +05:30
def self.integrations
2019-07-07 11:18:12 +05:30
{
'asana' => [
{
required: true,
name: :api_key,
type: String,
desc: 'User API token'
},
{
required: false,
name: :restrict_to_branch,
type: String,
desc: 'Comma-separated list of branches which will be automatically inspected. Leave blank to include all branches'
}
],
'assembla' => [
{
required: true,
name: :token,
type: String,
desc: 'The authentication token'
},
{
required: false,
name: :subdomain,
type: String,
desc: 'Subdomain setting'
}
],
'bamboo' => [
{
required: true,
name: :bamboo_url,
type: String,
desc: 'Bamboo root URL like https://bamboo.example.com'
},
2022-02-05 19:09:49 +05:30
{
required: false,
name: :enable_ssl_verification,
type: Boolean,
desc: 'Enable SSL verification'
},
2019-07-07 11:18:12 +05:30
{
required: true,
name: :build_key,
type: String,
desc: 'Bamboo build plan key like'
},
{
required: true,
name: :username,
type: String,
desc: 'A user with API access, if applicable'
},
{
required: true,
name: :password,
type: String,
desc: 'Password of the user'
}
],
'bugzilla' => [
{
required: true,
name: :new_issue_url,
type: String,
desc: 'New issue URL'
},
{
required: true,
name: :issues_url,
type: String,
desc: 'Issues URL'
},
{
required: true,
name: :project_url,
type: String,
desc: 'Project URL'
}
],
'buildkite' => [
{
required: true,
name: :token,
type: String,
desc: 'Buildkite project GitLab token'
},
{
required: true,
name: :project_url,
type: String,
2020-10-24 23:57:45 +05:30
desc: 'The Buildkite pipeline URL'
2019-07-07 11:18:12 +05:30
},
{
required: false,
name: :enable_ssl_verification,
type: Boolean,
2020-10-24 23:57:45 +05:30
desc: 'DEPRECATED: This parameter has no effect since SSL verification will always be enabled'
2019-07-07 11:18:12 +05:30
}
2021-12-11 22:18:48 +05:30
],
2019-07-07 11:18:12 +05:30
'campfire' => [
{
required: true,
name: :token,
type: String,
desc: 'Campfire token'
},
{
required: false,
name: :subdomain,
type: String,
desc: 'Campfire subdomain'
},
{
required: false,
name: :room,
type: String,
desc: 'Campfire room'
}
],
2020-07-28 23:09:34 +05:30
'confluence' => [
{
required: true,
name: :confluence_url,
type: String,
desc: 'The URL of the Confluence Cloud Workspace hosted on atlassian.net'
}
],
2019-07-07 11:18:12 +05:30
'custom-issue-tracker' => [
{
required: true,
name: :new_issue_url,
type: String,
desc: 'New issue URL'
},
{
required: true,
name: :issues_url,
type: String,
desc: 'Issues URL'
},
{
required: true,
name: :project_url,
type: String,
desc: 'Project URL'
}
],
2021-02-22 17:27:13 +05:30
'datadog' => [
{
required: true,
name: :api_key,
type: String,
desc: 'API key used for authentication with Datadog'
},
{
required: false,
name: :datadog_site,
type: String,
2022-03-02 08:16:31 +05:30
desc: 'The Datadog site to send data to. To send data to the EU site, use datadoghq.eu'
2021-02-22 17:27:13 +05:30
},
{
required: false,
name: :api_url,
type: String,
2022-03-02 08:16:31 +05:30
desc: '(Advanced) The full URL for your Datadog site'
2021-02-22 17:27:13 +05:30
},
2022-08-27 11:52:29 +05:30
{
required: false,
name: :archive_trace_events,
type: Boolean,
desc: 'When enabled, job logs will be collected by Datadog and shown along pipeline execution traces'
},
2021-02-22 17:27:13 +05:30
{
required: false,
name: :datadog_service,
type: String,
2022-03-02 08:16:31 +05:30
desc: 'Tag all data from this GitLab instance in Datadog. Useful when managing several self-managed deployments'
2021-02-22 17:27:13 +05:30
},
{
required: false,
name: :datadog_env,
type: String,
2022-04-04 11:22:00 +05:30
desc: 'For self-managed deployments, set the env tag for all the data sent to Datadog'
},
{
required: false,
name: :datadog_tags,
type: String,
desc: 'Custom tags in Datadog. Specify one tag per line in the format: "key:value\nkey2:value2"'
2021-02-22 17:27:13 +05:30
}
],
2019-07-07 11:18:12 +05:30
'discord' => [
{
required: true,
name: :webhook,
type: String,
2021-11-18 22:05:49 +05:30
desc: 'Discord webhook. For example, https://discord.com/api/webhooks/…'
2019-07-07 11:18:12 +05:30
}
],
'drone-ci' => [
{
required: true,
name: :token,
type: String,
desc: 'Drone CI token'
},
{
required: true,
name: :drone_url,
type: String,
desc: 'Drone CI URL'
},
{
required: false,
name: :enable_ssl_verification,
type: Boolean,
2022-02-05 19:09:49 +05:30
desc: 'Enable SSL verification'
2019-07-07 11:18:12 +05:30
}
],
'emails-on-push' => [
{
required: true,
name: :recipients,
type: String,
desc: 'Comma-separated list of recipient email addresses'
},
{
required: false,
name: :disable_diffs,
type: Boolean,
desc: 'Disable code diffs'
},
{
required: false,
name: :send_from_committer_email,
type: Boolean,
desc: 'Send from committer'
2020-03-13 15:44:24 +05:30
},
{
required: false,
name: :branches_to_be_notified,
type: String,
desc: 'Branches for which notifications are to be sent'
2019-07-07 11:18:12 +05:30
}
],
'external-wiki' => [
{
required: true,
name: :external_wiki_url,
type: String,
2021-04-29 21:17:54 +05:30
desc: 'The URL of the external wiki'
2019-07-07 11:18:12 +05:30
}
],
'flowdock' => [
{
required: true,
name: :token,
type: String,
desc: 'Flowdock token'
}
],
'hangouts-chat' => [
{
required: true,
name: :webhook,
type: String,
desc: 'The Hangouts Chat webhook. e.g. https://chat.googleapis.com/v1/spaces…'
},
2021-01-03 14:25:43 +05:30
{
required: false,
name: :branches_to_be_notified,
type: String,
desc: 'Branches for which notifications are to be sent'
},
2019-07-07 11:18:12 +05:30
chat_notification_events
].flatten,
2022-05-07 20:08:51 +05:30
'harbor' => [
{
required: true,
name: :url,
type: String,
desc: 'The base URL to the Harbor instance which is being linked to this GitLab project. For example, https://demo.goharbor.io.'
},
{
required: true,
name: :project_name,
type: String,
desc: 'The Project name to the Harbor instance. For example, testproject.'
},
{
required: true,
name: :username,
type: String,
desc: 'The username created from Harbor interface.'
},
{
required: true,
name: :password,
type: String,
desc: 'The password of the user.'
}
],
2019-07-07 11:18:12 +05:30
'irker' => [
{
required: true,
name: :recipients,
type: String,
desc: 'Recipients/channels separated by whitespaces'
},
{
required: false,
name: :default_irc_uri,
type: String,
desc: 'Default: irc://irc.network.net:6697'
},
{
required: false,
name: :server_host,
type: String,
desc: 'Server host. Default localhost'
},
{
required: false,
name: :server_port,
type: Integer,
desc: 'Server port. Default 6659'
},
{
required: false,
name: :colorize_messages,
type: Boolean,
desc: 'Colorize messages'
}
],
2021-02-22 17:27:13 +05:30
'jenkins' => [
{
required: true,
name: :jenkins_url,
type: String,
desc: 'Jenkins root URL like https://jenkins.example.com'
},
2022-02-05 19:09:49 +05:30
{
required: false,
name: :enable_ssl_verification,
type: Boolean,
desc: 'Enable SSL verification'
},
2021-02-22 17:27:13 +05:30
{
required: true,
name: :project_name,
type: String,
desc: 'The URL-friendly project name. Example: my_project_name'
},
{
required: false,
name: :username,
type: String,
desc: 'A user with access to the Jenkins server, if applicable'
},
{
required: false,
name: :password,
type: String,
desc: 'The password of the user'
}
],
2019-07-07 11:18:12 +05:30
'jira' => [
{
required: true,
name: :url,
type: String,
2019-09-30 21:07:59 +05:30
desc: 'The base URL to the Jira instance web interface which is being linked to this GitLab project. E.g., https://jira.example.com'
2019-07-07 11:18:12 +05:30
},
{
required: false,
name: :api_url,
type: String,
2019-09-30 21:07:59 +05:30
desc: 'The base URL to the Jira instance API. Web URL value will be used if not set. E.g., https://jira-api.example.com'
2019-07-07 11:18:12 +05:30
},
{
required: true,
name: :username,
type: String,
2019-09-30 21:07:59 +05:30
desc: 'The username of the user created to be used with GitLab/Jira'
2019-07-07 11:18:12 +05:30
},
{
required: true,
name: :password,
type: String,
2019-09-30 21:07:59 +05:30
desc: 'The password of the user created to be used with GitLab/Jira'
2019-07-07 11:18:12 +05:30
},
2021-04-29 21:17:54 +05:30
{
required: false,
name: :jira_issue_transition_automatic,
type: Boolean,
desc: 'Enable automatic issue transitions'
},
2019-07-07 11:18:12 +05:30
{
required: false,
name: :jira_issue_transition_id,
type: String,
2021-04-29 21:17:54 +05:30
desc: 'The ID of one or more transitions for custom issue transitions'
2020-01-01 13:55:28 +05:30
},
{
required: false,
name: :comment_on_event_enabled,
type: Boolean,
desc: 'Enable comments inside Jira issues on each GitLab event (commit / merge request)'
2019-07-07 11:18:12 +05:30
}
],
'mattermost-slash-commands' => [
{
required: true,
name: :token,
type: String,
desc: 'The Mattermost token'
}
],
2021-12-11 22:18:48 +05:30
'shimo' => [
{
required: true,
name: :external_wiki_url,
type: String,
desc: 'Shimo workspace URL'
}
],
2019-07-07 11:18:12 +05:30
'slack-slash-commands' => [
{
required: true,
name: :token,
type: String,
desc: 'The Slack token'
}
],
'packagist' => [
{
required: true,
name: :username,
type: String,
desc: 'The username'
},
{
required: true,
name: :token,
type: String,
desc: 'The Packagist API token'
},
{
required: false,
name: :server,
type: String,
desc: 'The server'
}
],
'pipelines-email' => [
{
required: true,
name: :recipients,
type: String,
desc: 'Comma-separated list of recipient email addresses'
},
{
required: false,
name: :notify_only_broken_pipelines,
type: Boolean,
desc: 'Notify only broken pipelines'
2019-09-04 21:01:54 +05:30
},
2022-08-13 15:12:31 +05:30
{
required: false,
name: :notify_only_default_branch,
type: Boolean,
desc: 'Send notifications only for the default branch'
},
2019-09-04 21:01:54 +05:30
{
required: false,
2019-12-04 20:38:33 +05:30
name: :branches_to_be_notified,
type: String,
desc: 'Branches for which notifications are to be sent'
2019-07-07 11:18:12 +05:30
}
],
'pivotaltracker' => [
{
required: true,
name: :token,
type: String,
desc: 'The Pivotaltracker token'
},
{
required: false,
name: :restrict_to_branch,
type: String,
desc: 'Comma-separated list of branches which will be automatically inspected. Leave blank to include all branches.'
}
],
'prometheus' => [
{
required: true,
name: :api_url,
type: String,
desc: 'Prometheus API Base URL, like http://prometheus.example.com/'
2020-06-23 00:09:42 +05:30
},
{
required: true,
name: :google_iap_audience_client_id,
type: String,
2021-04-17 20:07:23 +05:30
desc: 'Client ID of the IAP-secured resource (looks like IAP_CLIENT_ID.apps.googleusercontent.com)'
2020-06-23 00:09:42 +05:30
},
{
required: true,
name: :google_iap_service_account_json,
type: String,
desc: 'Contents of the credentials.json file of your service account, like: { "type": "service_account", "project_id": ... }'
2019-07-07 11:18:12 +05:30
}
],
2022-08-27 11:52:29 +05:30
'pumble' => [
{
required: true,
name: :webhook,
type: String,
desc: 'The Pumble chat webhook. For example, https://api.pumble.com/workspaces/x/...'
},
chat_notification_events
].flatten,
2019-07-07 11:18:12 +05:30
'pushover' => [
{
required: true,
name: :api_key,
type: String,
desc: 'The application key'
},
{
required: true,
name: :user_key,
type: String,
desc: 'The user key'
},
{
required: true,
name: :priority,
type: String,
desc: 'The priority'
},
{
required: true,
name: :device,
type: String,
desc: 'Leave blank for all active devices'
},
{
required: true,
name: :sound,
type: String,
desc: 'The sound of the notification'
}
],
'redmine' => [
{
required: true,
name: :new_issue_url,
type: String,
desc: 'The new issue URL'
},
{
required: true,
name: :project_url,
type: String,
desc: 'The project URL'
},
{
required: true,
name: :issues_url,
type: String,
desc: 'The issues URL'
2020-11-24 15:15:51 +05:30
}
],
'ewm' => [
{
required: true,
name: :new_issue_url,
type: String,
desc: 'New Issue URL'
2019-07-07 11:18:12 +05:30
},
{
2020-11-24 15:15:51 +05:30
required: true,
name: :project_url,
type: String,
desc: 'Project URL'
},
{
required: true,
name: :issues_url,
2019-07-07 11:18:12 +05:30
type: String,
2020-11-24 15:15:51 +05:30
desc: 'Issues URL'
2019-07-07 11:18:12 +05:30
}
],
'youtrack' => [
{
required: true,
name: :project_url,
type: String,
desc: 'The project URL'
},
{
required: true,
name: :issues_url,
type: String,
desc: 'The issues URL'
}
],
'slack' => [
chat_notification_settings,
chat_notification_flags,
chat_notification_channels,
chat_notification_events
].flatten,
'microsoft-teams' => [
{
required: true,
name: :webhook,
type: String,
desc: 'The Microsoft Teams webhook. e.g. https://outlook.office.com/webhook/…'
2019-09-04 21:01:54 +05:30
},
2020-03-13 15:44:24 +05:30
{
required: false,
name: :branches_to_be_notified,
type: String,
desc: 'Branches for which notifications are to be sent'
},
2019-09-04 21:01:54 +05:30
chat_notification_flags
].flatten,
2019-07-07 11:18:12 +05:30
'mattermost' => [
chat_notification_settings,
chat_notification_flags,
chat_notification_channels,
chat_notification_events
].flatten,
'teamcity' => [
{
required: true,
name: :teamcity_url,
type: String,
desc: 'TeamCity root URL like https://teamcity.example.com'
},
2022-02-05 19:09:49 +05:30
{
required: false,
name: :enable_ssl_verification,
type: Boolean,
desc: 'Enable SSL verification'
},
2019-07-07 11:18:12 +05:30
{
required: true,
name: :build_type,
type: String,
desc: 'Build configuration ID'
},
{
required: true,
name: :username,
type: String,
desc: 'A user with permissions to trigger a manual build'
},
{
required: true,
name: :password,
type: String,
desc: 'The password of the user'
}
2020-01-01 13:55:28 +05:30
],
'unify-circuit' => [
{
required: true,
name: :webhook,
type: String,
desc: 'The Unify Circuit webhook. e.g. https://circuit.com/rest/v2/webhooks/incoming/…'
},
chat_notification_events
2020-05-24 23:13:21 +05:30
].flatten,
'webex-teams' => [
{
required: true,
name: :webhook,
type: String,
2021-06-08 01:23:25 +05:30
desc: 'The Webex Teams webhook. For example, https://api.ciscospark.com/v1/webhooks/incoming/...'
2020-05-24 23:13:21 +05:30
},
chat_notification_events
2021-12-11 22:18:48 +05:30
].flatten,
'zentao' => [
{
required: true,
name: :url,
type: String,
desc: 'The base URL to the ZenTao instance web interface which is being linked to this GitLab project. For example, https://www.zentao.net'
},
{
required: false,
name: :api_url,
type: String,
desc: 'The base URL to the ZenTao instance API. Web URL value will be used if not set. For example, https://www.zentao.net'
},
{
required: true,
name: :api_token,
type: String,
desc: 'The API token created from ZenTao dashboard'
},
{
required: true,
name: :zentao_product_xid,
type: String,
desc: 'The product ID of ZenTao project'
}
]
2019-07-07 11:18:12 +05:30
}
end
2021-09-30 23:02:18 +05:30
def self.integration_classes
2019-07-07 11:18:12 +05:30
[
2021-06-08 01:23:25 +05:30
::Integrations::Asana,
::Integrations::Assembla,
::Integrations::Bamboo,
2021-09-04 01:27:46 +05:30
::Integrations::Bugzilla,
::Integrations::Buildkite,
2021-06-08 01:23:25 +05:30
::Integrations::Campfire,
::Integrations::Confluence,
2021-09-04 01:27:46 +05:30
::Integrations::CustomIssueTracker,
2021-06-08 01:23:25 +05:30
::Integrations::Datadog,
2021-09-04 01:27:46 +05:30
::Integrations::Discord,
::Integrations::DroneCi,
2021-06-08 01:23:25 +05:30
::Integrations::EmailsOnPush,
2021-09-04 01:27:46 +05:30
::Integrations::Ewm,
::Integrations::ExternalWiki,
::Integrations::Flowdock,
::Integrations::HangoutsChat,
2022-05-07 20:08:51 +05:30
::Integrations::Harbor,
2021-09-04 01:27:46 +05:30
::Integrations::Irker,
::Integrations::Jenkins,
::Integrations::Jira,
::Integrations::Mattermost,
::Integrations::MattermostSlashCommands,
::Integrations::MicrosoftTeams,
::Integrations::Packagist,
::Integrations::PipelinesEmail,
::Integrations::Pivotaltracker,
2021-09-30 23:02:18 +05:30
::Integrations::Prometheus,
2021-09-04 01:27:46 +05:30
::Integrations::Pushover,
::Integrations::Redmine,
::Integrations::Slack,
::Integrations::SlackSlashCommands,
::Integrations::Teamcity,
2021-12-11 22:18:48 +05:30
::Integrations::Youtrack,
::Integrations::Zentao
2019-07-07 11:18:12 +05:30
]
end
2021-09-30 23:02:18 +05:30
def self.development_integration_classes
2019-07-07 11:18:12 +05:30
[
2021-09-04 01:27:46 +05:30
::Integrations::MockCi,
2021-09-30 23:02:18 +05:30
::Integrations::MockMonitoring
2019-07-07 11:18:12 +05:30
]
end
end
end
end
2019-12-04 20:38:33 +05:30
2021-09-30 23:02:18 +05:30
API::Helpers::IntegrationsHelpers.prepend_mod_with('API::Helpers::IntegrationsHelpers')