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
b30e0e06
Commit
b30e0e06
authored
Dec 08, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix invalid pipeline build chain tag evaluation
parent
fe62860e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
8 deletions
+69
-8
lib/gitlab/ci/pipeline/chain/build.rb
lib/gitlab/ci/pipeline/chain/build.rb
+4
-2
lib/gitlab/ci/pipeline/chain/helpers.rb
lib/gitlab/ci/pipeline/chain/helpers.rb
+10
-4
spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
+35
-2
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+20
-0
No files found.
lib/gitlab/ci/pipeline/chain/build.rb
View file @
b30e0e06
...
...
@@ -3,8 +3,6 @@ module Gitlab
module
Pipeline
module
Chain
class
Build
<
Chain
::
Base
include
Chain
::
Helpers
def
perform!
@pipeline
.
assign_attributes
(
source:
@command
.
source
,
...
...
@@ -51,6 +49,10 @@ module Gitlab
def
protected_ref?
@project
.
protected_for?
(
ref
)
end
def
tag_exists?
project
.
repository
.
tag_exists?
(
ref
)
end
end
end
end
...
...
lib/gitlab/ci/pipeline/chain/helpers.rb
View file @
b30e0e06
...
...
@@ -3,16 +3,22 @@ module Gitlab
module
Pipeline
module
Chain
module
Helpers
include
Gitlab
::
Utils
::
StrongMemoize
def
branch_exists?
return
@is_branch
if
defined?
(
@is_branch
)
strong_memoize
(
:is_branch
)
do
raise
ArgumentError
unless
pipeline
.
ref
@is_branch
=
project
.
repository
.
branch_exists?
(
pipeline
.
ref
)
project
.
repository
.
branch_exists?
(
pipeline
.
ref
)
end
end
def
tag_exists?
return
@is_tag
if
defined?
(
@is_tag
)
strong_memoize
(
:is_tag
)
do
raise
ArgumentError
unless
pipeline
.
ref
@is_tag
=
project
.
repository
.
tag_exists?
(
pipeline
.
ref
)
project
.
repository
.
tag_exists?
(
pipeline
.
ref
)
end
end
def
error
(
message
)
...
...
spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
View file @
b30e0e06
...
...
@@ -21,31 +21,64 @@ describe Gitlab::Ci::Pipeline::Chain::Build do
before
do
stub_repository_ci_yaml_file
(
sha:
anything
)
step
.
perform!
end
it
'never breaks the chain'
do
step
.
perform!
expect
(
step
.
break?
).
to
be
false
end
it
'fills pipeline object with data'
do
step
.
perform!
expect
(
pipeline
.
sha
).
not_to
be_empty
expect
(
pipeline
.
sha
).
to
eq
project
.
commit
.
id
expect
(
pipeline
.
ref
).
to
eq
'master'
expect
(
pipeline
.
tag
).
to
be
false
expect
(
pipeline
.
user
).
to
eq
user
expect
(
pipeline
.
project
).
to
eq
project
end
it
'sets a valid config source'
do
step
.
perform!
expect
(
pipeline
.
repository_source?
).
to
be
true
end
it
'returns a valid pipeline'
do
step
.
perform!
expect
(
pipeline
).
to
be_valid
end
it
'does not persist a pipeline'
do
step
.
perform!
expect
(
pipeline
).
not_to
be_persisted
end
context
'when pipeline is running for a tag'
do
let
(
:command
)
do
double
(
'command'
,
source: :push
,
origin_ref:
'mytag'
,
checkout_sha:
project
.
commit
.
id
,
after_sha:
nil
,
before_sha:
nil
,
trigger_request:
nil
,
schedule:
nil
,
project:
project
,
current_user:
user
)
end
before
do
allow
(
step
).
to
receive
(
:tag_exists?
).
and_return
(
true
)
step
.
perform!
end
it
'correctly indicated that this is a tagged pipeline'
do
expect
(
pipeline
).
to
be_tag
end
end
end
spec/services/ci/create_pipeline_service_spec.rb
View file @
b30e0e06
...
...
@@ -518,5 +518,25 @@ describe Ci::CreatePipelineService do
end
end
end
context
'when pipelie is running for a tag'
do
before
do
allow_any_instance_of
(
Repository
)
.
to
receive
(
:tag_exists?
).
and_return
(
false
)
allow_any_instance_of
(
Repository
)
.
to
receive
(
:tag_exists?
).
with
(
'refs/tags/mytag'
).
and_return
(
true
)
config
=
YAML
.
dump
(
test:
{
script:
'test'
,
only:
[
'branches'
]
},
deploy:
{
script:
'deploy'
,
only:
[
'tags'
]
})
stub_ci_pipeline_yaml_file
(
config
)
end
it
'creates a tagged pipeline'
do
pipeline
=
execute_service
(
ref:
'mytag'
)
expect
(
pipeline
.
tag?
).
to
be
true
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