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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
9e06bde2
Commit
9e06bde2
authored
Aug 03, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure we only fire hooks upon status changed
parent
3691a391
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+3
-3
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+21
-1
No files found.
app/models/ci/pipeline.rb
View file @
9e06bde2
...
@@ -18,7 +18,7 @@ module Ci
...
@@ -18,7 +18,7 @@ module Ci
# Invalidate object and save if when touched
# Invalidate object and save if when touched
after_touch
:update_state
after_touch
:update_state
after_
touch
:execute_hooks_unless_ci_skipp
ed
after_
save
:execute_hooks_if_status_chang
ed
after_save
:keep_around_commits
after_save
:keep_around_commits
# ref can't be HEAD or SHA, can only be branch/tag name
# ref can't be HEAD or SHA, can only be branch/tag name
...
@@ -241,8 +241,8 @@ module Ci
...
@@ -241,8 +241,8 @@ module Ci
save
save
end
end
def
execute_hooks_
unless_ci_skipp
ed
def
execute_hooks_
if_status_chang
ed
execute_hooks
unless
skip_ci?
execute_hooks
if
status_changed?
&&
!
skip_ci?
end
end
def
execute_hooks
def
execute_hooks
...
...
spec/models/ci/pipeline_spec.rb
View file @
9e06bde2
...
@@ -551,7 +551,7 @@ describe Ci::Pipeline, models: true do
...
@@ -551,7 +551,7 @@ describe Ci::Pipeline, models: true do
before
do
before
do
WebMock
.
stub_request
(
:post
,
hook
.
url
)
WebMock
.
stub_request
(
:post
,
hook
.
url
)
pipeline
.
touch
pipeline
.
save
ProjectWebHookWorker
.
drain
ProjectWebHookWorker
.
drain
end
end
...
@@ -561,6 +561,26 @@ describe Ci::Pipeline, models: true do
...
@@ -561,6 +561,26 @@ describe Ci::Pipeline, models: true do
it
'executes pipeline_hook after touched'
do
it
'executes pipeline_hook after touched'
do
expect
(
WebMock
).
to
have_requested
(
:post
,
hook
.
url
).
once
expect
(
WebMock
).
to
have_requested
(
:post
,
hook
.
url
).
once
end
end
context
'with multiple builds'
do
def
create_build
(
name
)
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
name:
name
)
end
let
(
:build_a
)
{
create_build
(
'a'
)
}
let
(
:build_b
)
{
create_build
(
'b'
)
}
before
do
build_a
.
run
build_b
.
run
build_a
.
success
build_b
.
success
end
it
'fires 3 hooks'
do
expect
(
WebMock
).
to
have_requested
(
:post
,
hook
.
url
).
times
(
3
)
end
end
end
end
context
'with pipeline hooks disabled'
do
context
'with pipeline hooks disabled'
do
...
...
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