Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3ffbf03c
Commit
3ffbf03c
authored
Aug 10, 2020
by
Vladimir Shushlin
Committed by
Bob Van Landuyt
Aug 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fire webhook on new deployment
parent
07796207
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
2 deletions
+29
-2
app/models/concerns/triggerable_hooks.rb
app/models/concerns/triggerable_hooks.rb
+2
-1
app/models/deployment.rb
app/models/deployment.rb
+1
-0
app/models/hooks/project_hook.rb
app/models/hooks/project_hook.rb
+2
-1
spec/workers/deployments/finished_worker_spec.rb
spec/workers/deployments/finished_worker_spec.rb
+24
-0
No files found.
app/models/concerns/triggerable_hooks.rb
View file @
3ffbf03c
...
@@ -12,7 +12,8 @@ module TriggerableHooks
...
@@ -12,7 +12,8 @@ module TriggerableHooks
merge_request_hooks: :merge_requests_events
,
merge_request_hooks: :merge_requests_events
,
job_hooks: :job_events
,
job_hooks: :job_events
,
pipeline_hooks: :pipeline_events
,
pipeline_hooks: :pipeline_events
,
wiki_page_hooks: :wiki_page_events
wiki_page_hooks: :wiki_page_events
,
deployment_hooks: :deployment_events
}.
freeze
}.
freeze
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
...
...
app/models/deployment.rb
View file @
3ffbf03c
...
@@ -148,6 +148,7 @@ class Deployment < ApplicationRecord
...
@@ -148,6 +148,7 @@ class Deployment < ApplicationRecord
def
execute_hooks
def
execute_hooks
deployment_data
=
Gitlab
::
DataBuilder
::
Deployment
.
build
(
self
)
deployment_data
=
Gitlab
::
DataBuilder
::
Deployment
.
build
(
self
)
project
.
execute_hooks
(
deployment_data
,
:deployment_hooks
)
if
Feature
.
enabled?
(
:deployment_webhooks
,
project
)
project
.
execute_services
(
deployment_data
,
:deployment_hooks
)
project
.
execute_services
(
deployment_data
,
:deployment_hooks
)
end
end
...
...
app/models/hooks/project_hook.rb
View file @
3ffbf03c
...
@@ -17,7 +17,8 @@ class ProjectHook < WebHook
...
@@ -17,7 +17,8 @@ class ProjectHook < WebHook
:merge_request_hooks
,
:merge_request_hooks
,
:job_hooks
,
:job_hooks
,
:pipeline_hooks
,
:pipeline_hooks
,
:wiki_page_hooks
:wiki_page_hooks
,
:deployment_hooks
]
]
belongs_to
:project
belongs_to
:project
...
...
spec/workers/deployments/finished_worker_spec.rb
View file @
3ffbf03c
...
@@ -49,5 +49,29 @@ RSpec.describe Deployments::FinishedWorker do
...
@@ -49,5 +49,29 @@ RSpec.describe Deployments::FinishedWorker do
expect
(
ProjectServiceWorker
).
not_to
have_received
(
:perform_async
)
expect
(
ProjectServiceWorker
).
not_to
have_received
(
:perform_async
)
end
end
it
'execute webhooks'
do
deployment
=
create
(
:deployment
)
project
=
deployment
.
project
web_hook
=
create
(
:project_hook
,
deployment_events:
true
,
project:
project
)
expect_next_instance_of
(
WebHookService
,
web_hook
,
an_instance_of
(
Hash
),
"deployment_hooks"
)
do
|
service
|
expect
(
service
).
to
receive
(
:async_execute
)
end
worker
.
perform
(
deployment
.
id
)
end
it
'does not execute webhooks if feature flag is disabled'
do
stub_feature_flags
(
deployment_webhooks:
false
)
deployment
=
create
(
:deployment
)
project
=
deployment
.
project
create
(
:project_hook
,
deployment_events:
true
,
project:
project
)
expect
(
WebHookService
).
not_to
receive
(
:new
)
worker
.
perform
(
deployment
.
id
)
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment