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
Boxiang Sun
gitlab-ce
Commits
2432d5bd
Commit
2432d5bd
authored
Sep 26, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for builder chain step that skipps pipelines
parent
1a8777c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
1 deletion
+86
-1
lib/gitlab/ci/pipeline/chain/skip.rb
lib/gitlab/ci/pipeline/chain/skip.rb
+1
-1
spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb
spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb
+85
-0
No files found.
lib/gitlab/ci/pipeline/chain/skip.rb
View file @
2432d5bd
...
...
@@ -24,7 +24,7 @@ module Gitlab
def
commit_message_skips_ci?
return
false
unless
@pipeline
.
git_commit_message
@skipped
||=
@pipeline
.
git_commit_message
=~
SKIP_PATTERN
@skipped
||=
!!
(
@pipeline
.
git_commit_message
=~
SKIP_PATTERN
)
end
end
end
...
...
spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb
0 → 100644
View file @
2432d5bd
require
'spec_helper'
describe
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Skip
do
set
(
:project
)
{
create
(
:project
)
}
set
(
:user
)
{
create
(
:user
)
}
set
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:command
)
do
double
(
'command'
,
project:
project
,
current_user:
user
,
ignore_skip_ci:
false
,
save_incompleted:
true
)
end
let
(
:step
)
{
described_class
.
new
(
pipeline
,
command
)
}
context
'when pipeline has been skipped by a user'
do
before
do
allow
(
pipeline
).
to
receive
(
:git_commit_message
)
.
and_return
(
'commit message [ci skip]'
)
step
.
perform!
end
it
'should break the chain'
do
expect
(
step
.
break?
).
to
be
true
end
it
'skips the pipeline'
do
expect
(
pipeline
.
reload
).
to
be_skipped
end
end
context
'when pipeline has not been skipped'
do
before
do
step
.
perform!
end
it
'should not break the chain'
do
expect
(
step
.
break?
).
to
be
false
end
it
'should not skip a pipeline chain'
do
expect
(
pipeline
.
reload
).
not_to
be_skipped
end
end
context
'when [ci skip] should be ignored'
do
let
(
:command
)
do
double
(
'command'
,
project:
project
,
current_user:
user
,
ignore_skip_ci:
true
)
end
it
'does not break the chain'
do
step
.
perform!
expect
(
step
.
break?
).
to
be
false
end
end
context
'when pipeline should be skipped but not persisted'
do
let
(
:command
)
do
double
(
'command'
,
project:
project
,
current_user:
user
,
ignore_skip_ci:
false
,
save_incompleted:
false
)
end
before
do
allow
(
pipeline
).
to
receive
(
:git_commit_message
)
.
and_return
(
'commit message [ci skip]'
)
step
.
perform!
end
it
'breaks the chain'
do
expect
(
step
.
break?
).
to
be
true
end
it
'does not skip pipeline'
do
expect
(
pipeline
.
reload
).
not_to
be_skipped
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