Commit 4b57eb47 authored by Sebastian Leuser's avatar Sebastian Leuser

Included Webex Teams Service based on the Unify Circuit Service

parent 62afdd63
......@@ -177,6 +177,7 @@ class Project < ApplicationRecord
has_one :packagist_service
has_one :hangouts_chat_service
has_one :unify_circuit_service
has_one :webex_teams_service
has_one :root_of_fork_network,
foreign_key: 'root_project_id',
......
# frozen_string_literal: true
class WebexTeamsService < ChatNotificationService
def title
'Webex Teams'
end
def description
'Receive event notifications in Webex Teams'
end
def self.to_param
'webex_teams'
end
def help
'This service sends notifications about projects events to a Webex Teams conversation.<br />
To set up this service:
<ol>
<li><a href="https://apphub.webex.com/teams/applications/incoming-webhooks-cisco-systems">Set up an incoming webhook for your conversation</a>. All notifications will come to this conversation.</li>
<li>Paste the <strong>Webhook URL</strong> into the field below.</li>
<li>Select events below to enable notifications.</li>
</ol>'
end
def event_field(event)
end
def default_channel_placeholder
end
def self.supported_events
%w[push issue confidential_issue merge_request note confidential_note tag_push
pipeline wiki_page]
end
def default_fields
[
{ type: 'text', name: 'webhook', placeholder: "e.g. https://api.ciscospark.com/v1/webhooks/incoming/…", required: true },
{ type: 'checkbox', name: 'notify_only_broken_pipelines' },
{ type: 'select', name: 'branches_to_be_notified', choices: branch_choices }
]
end
private
def notify(message, opts)
@header = { 'Content-type' => 'application/json' }
response = Gitlab::HTTP.post(webhook, headers: @header, body: { markdown: message.pretext }.to_json)
response if response.success?
end
def custom_data(data)
super(data).merge(markdown: true)
end
end
......@@ -12,7 +12,7 @@ class Service < ApplicationRecord
alerts asana assembla bamboo bugzilla buildkite campfire custom_issue_tracker discord
drone_ci emails_on_push external_wiki flowdock hangouts_chat hipchat irker jira
mattermost mattermost_slash_commands microsoft_teams packagist pipelines_email
pivotaltracker prometheus pushover redmine slack slack_slash_commands teamcity unify_circuit youtrack
pivotaltracker prometheus pushover redmine slack slack_slash_commands teamcity unify_circuit webex_teams youtrack
].freeze
DEV_SERVICE_NAMES = %w[
......
......@@ -27215,6 +27215,12 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "WEBEX_TEAMS_SERVICE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "YOUTRACK_SERVICE",
"description": null,
......
......@@ -331,6 +331,51 @@ Get Unify Circuit service settings for a project.
GET /projects/:id/services/unify-circuit
```
## Webex Teams
Webex Teams collaboration tool.
### Create/Edit Webex Teams service
Set Webex Teams service for a project.
```plaintext
PUT /projects/:id/services/webex-teams
```
Parameters:
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `webhook` | string | true | The Webex Teams webhook. For example, `https://api.ciscospark.com/v1/webhooks/incoming/...`. |
| `notify_only_broken_pipelines` | boolean | false | Send notifications for broken pipelines |
| `branches_to_be_notified` | string | all | Branches to send notifications for. Valid options are "all", "default", "protected", and "default_and_protected" |
| `push_events` | boolean | false | Enable notifications for push events |
| `issues_events` | boolean | false | Enable notifications for issue events |
| `confidential_issues_events` | boolean | false | Enable notifications for confidential issue events |
| `merge_requests_events` | boolean | false | Enable notifications for merge request events |
| `tag_push_events` | boolean | false | Enable notifications for tag push events |
| `note_events` | boolean | false | Enable notifications for note events |
| `confidential_note_events` | boolean | false | Enable notifications for confidential note events |
| `pipeline_events` | boolean | false | Enable notifications for pipeline events |
| `wiki_page_events` | boolean | false | Enable notifications for wiki page events |
### Delete Webex Teams service
Delete Webex Teams service for a project.
```plaintext
DELETE /projects/:id/services/webex-teams
```
### Get Webex Teams service settings
Get Webex Teams service settings for a project.
```plaintext
GET /projects/:id/services/webex-teams
```
## Custom Issue Tracker
Custom issue tracker
......
# Webex Teams service
The Webex Teams service sends notifications from GitLab to the conversation for which the webhook was created.
## On Webex Teams
1. Open <https://apphub.webex.com/teams/applications/incoming-webhooks-cisco-systems> in your browser
1. Click on **Connect** Button and authenticate yourself if required
1. Scroll down and define the name of the webhook in the conversation and select the space for the webhook.
1. Click **ADD**
1. Click **SAVE** and copy the **Webhook URL** of your webhook.
For more information, see the [Webex Teams documentation for configuring incoming webhooks](https://apphub.webex.com/teams/applications/incoming-webhooks-cisco-systems).
## On GitLab
When you have the **Webhook URL** for your Webex Teams conversation webhook, you can set up the GitLab service.
1. Navigate to the [Integrations page](overview.md#accessing-integrations) in your project's settings, i.e. **Project > Settings > Integrations**.
1. Select the **Webex Teams** integration to configure it.
1. Ensure that the **Active** toggle is enabled.
1. Check the checkboxes corresponding to the GitLab events you want to receive in Unify Circuit.
1. Paste the **Webhook URL** that you copied from the Webex Teams configuration step.
1. Configure the remaining options and click `Save changes`.
Your Webex Teams conversation will now start receiving GitLab event notifications as configured.
![Webex Teams configuration](img/unify_circuit_configuration.png)
......@@ -724,6 +724,15 @@ module API
desc: 'The Unify Circuit webhook. e.g. https://circuit.com/rest/v2/webhooks/incoming/…'
},
chat_notification_events
].flatten,
'webex-teams' => [
{
required: true,
name: :webhook,
type: String,
desc: 'The Webex Teams webhook. e.g. https://api.ciscospark.com/v1/webhooks/incoming/…'
},
chat_notification_events
].flatten
}
end
......
# frozen_string_literal: true
require "spec_helper"
describe WebexTeamsService do
it_behaves_like "chat service", "Webex Teams" do
let(:client_arguments) { webhook_url }
let(:content_key) { :markdown }
end
end
......@@ -36,6 +36,7 @@ describe Project do
it { is_expected.to have_one(:mattermost_service) }
it { is_expected.to have_one(:hangouts_chat_service) }
it { is_expected.to have_one(:unify_circuit_service) }
it { is_expected.to have_one(:webex_teams_service) }
it { is_expected.to have_one(:packagist_service) }
it { is_expected.to have_one(:pushover_service) }
it { is_expected.to have_one(:asana_service) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment