Commit 0b61ce4c authored by Vladimir Shushlin's avatar Vladimir Shushlin

Add deployment events to group webhooks

We recently released deployment webhooks on the project level,
but have forgotten about group interface for them.

Interface re-uses the same view, but the parameter is not
whitelisted for group-webhooks.

So this commit:
- adds "deployment_events" to triggerable events for group
- adds it to controller whitelist(and refactors it a little)
- adds it the API params and response
- adds it to group hooks API docs
parent 91e71c4f
......@@ -941,6 +941,7 @@ GET /groups/:id/hooks/:hook_id
"job_events": true,
"pipeline_events": true,
"wiki_page_events": true,
"deployment_events": true,
"enable_ssl_verification": true,
"created_at": "2012-10-12T17:04:47Z"
}
......@@ -968,6 +969,7 @@ POST /groups/:id/hooks
| `job_events` | boolean | no | Trigger hook on job events |
| `pipeline_events` | boolean | no | Trigger hook on pipeline events |
| `wiki_page_events` | boolean | no | Trigger hook on wiki events |
| `deployment_events` | boolean | no | Trigger hook on deployment events |
| `enable_ssl_verification` | boolean | no | Do SSL verification when triggering the hook |
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
......@@ -994,6 +996,7 @@ PUT /groups/:id/hooks/:hook_id
| `job_events` | boolean | no | Trigger hook on job events |
| `pipeline_events` | boolean | no | Trigger hook on pipeline events |
| `wiki_events` | boolean | no | Trigger hook on wiki events |
| `deployment_events` | boolean | no | Trigger hook on deployment events |
| `enable_ssl_verification` | boolean | no | Do SSL verification when triggering the hook |
| `token` | string | no | Secret token to validate received payloads; this will not be returned in the response |
......
......@@ -70,18 +70,10 @@ class Groups::HooksController < Groups::ApplicationController
def hook_params
params.require(:hook).permit(
:job_events,
:confidential_issues_events,
:enable_ssl_verification,
:issues_events,
:merge_requests_events,
:note_events,
:pipeline_events,
:push_events,
:tag_push_events,
:token,
:url,
:wiki_page_events
*GroupHook.triggers.values
)
end
......
......@@ -18,7 +18,8 @@ class GroupHook < WebHook
:merge_request_hooks,
:job_hooks,
:pipeline_hooks,
:wiki_page_hooks
:wiki_page_hooks,
:deployment_hooks
]
belongs_to :group
......
---
title: Add deployment events to group webhooks
merge_request: 40270
author:
type: added
......@@ -20,6 +20,7 @@ module API
optional :job_events, type: Boolean, desc: "Trigger hook on job events"
optional :pipeline_events, type: Boolean, desc: "Trigger hook on pipeline events"
optional :wiki_page_events, type: Boolean, desc: "Trigger hook on wiki events"
optional :deployment_events, type: Boolean, desc: "Trigger hook on deployment events"
optional :enable_ssl_verification, type: Boolean, desc: "Do SSL verification when triggering the hook"
optional :token, type: String, desc: "Secret token to validate received payloads; this will not be returned in the response"
end
......
......@@ -6,7 +6,7 @@ module EE
class GroupHook < ::API::Entities::Hook
expose :group_id, :issues_events, :confidential_issues_events,
:note_events, :confidential_note_events, :pipeline_events, :wiki_page_events,
:job_events
:job_events, :deployment_events
end
end
end
......
......@@ -38,7 +38,8 @@ RSpec.describe Groups::HooksController do
tag_push_events: true,
token: 'TEST TOKEN',
url: 'http://example.com',
wiki_page_events: true
wiki_page_events: true,
deployment_events: true
}
post :create, params: { group_id: group.to_param, hook: hook_params }
......@@ -78,7 +79,8 @@ RSpec.describe Groups::HooksController do
tag_push_events: true,
token: 'TEST TOKEN',
url: 'http://example.com',
wiki_page_events: true
wiki_page_events: true,
deployment_events: true
}
end
......
......@@ -16,7 +16,8 @@
"confidential_note_events",
"pipeline_events",
"wiki_page_events",
"job_events"
"job_events",
"deployment_events"
],
"properties": {
"id": { "type": "integer" },
......@@ -34,7 +35,8 @@
"confidential_note_events": { "type": ["boolean", "null"] },
"pipeline_events": { "type": "boolean" },
"wiki_page_events": { "type": "boolean" },
"job_events": { "type": "boolean" }
"job_events": { "type": "boolean" },
"deployment_events": { "type": "boolean" }
},
"additionalProperties": false
}
......@@ -106,6 +106,23 @@ RSpec.describe API::GroupHooks do
end
describe "POST /groups/:id/hooks" do
let(:hook_params) do
{
url: "http://example.com",
push_events: true,
issues_events: true,
confidential_issues_events: true,
merge_requests_events: true,
tag_push_events: true,
note_events: true,
confidential_note_events: true,
job_events: true,
pipeline_events: true,
wiki_page_events: true,
deployment_events: true
}
end
context "authorized user" do
it "adds a new hook to group" do
expect do
......@@ -114,6 +131,20 @@ RSpec.describe API::GroupHooks do
expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/group_hook', dir: 'ee')
expect(json_response['url']).to eq('http://example.com')
expect(json_response['issues_events']).to eq(true)
expect(json_response['confidential_issues_events']).to eq(true)
expect(json_response['push_events']).to eq(true)
expect(json_response['merge_requests_events']).to eq(true)
expect(json_response['tag_push_events']).to eq(true)
expect(json_response['note_events']).to eq(true)
expect(json_response['confidential_note_events']).to eq(true)
expect(json_response['job_events']).to eq(true)
expect(json_response['pipeline_events']).to eq(true)
expect(json_response['wiki_page_events']).to eq(true)
expect(json_response['deployment_events']).to eq(true)
expect(json_response['enable_ssl_verification']).to eq(true)
end
it "returns 400 if url is not given" do
......
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