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
dd9d8ce8
Commit
dd9d8ce8
authored
Mar 01, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix runner tags assignment when retrying a job
parent
48d7ed63
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
23 deletions
+41
-23
app/services/ci/retry_build_service.rb
app/services/ci/retry_build_service.rb
+17
-14
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+4
-0
spec/services/ci/retry_build_service_spec.rb
spec/services/ci/retry_build_service_spec.rb
+20
-9
No files found.
app/services/ci/retry_build_service.rb
View file @
dd9d8ce8
module
Ci
module
Ci
class
RetryBuildService
<
::
BaseService
class
RetryBuildService
<
::
BaseService
CLONE_A
TTRIBUTE
S
=
%i[pipeline project ref tag options commands name
CLONE_A
CCESSOR
S
=
%i[pipeline project ref tag options commands name
allow_failure stage stage_idx trigger_request
allow_failure stage stage_idx trigger_request
yaml_variables when environment coverage_regex]
yaml_variables when environment coverage_regex
.
freeze
description tag_list]
.
freeze
REJECT_A
TTRIBUTE
S
=
%i[id status user token coverage trace runner
REJECT_A
CCESSOR
S
=
%i[id status user token coverage trace runner
artifacts_expire_at artifacts_file
artifacts_expire_at artifacts_file
artifacts_metadata artifacts_size
artifacts_metadata artifacts_size
created_at updated_at started_at finished_at
created_at updated_at started_at finished_at
queued_at erased_by erased_at]
.
freeze
queued_at erased_by erased_at]
.
freeze
IGNORE_ATTRIBUTES
=
%i[type lock_version gl_project_id target_url
IGNORE_ACCESSORS
=
%i[type lock_version target_url gl_project_id
deploy job_id description]
.
freeze
deploy job_id base_tags commit_id deployments
erased_by_id last_deployment project_id runner_id
tag_taggings taggings tags trigger_request_id
user_id]
.
freeze
def
execute
(
build
)
def
execute
(
build
)
reprocess
(
build
).
tap
do
|
new_build
|
reprocess
(
build
).
tap
do
|
new_build
|
...
@@ -31,7 +34,7 @@ module Ci
...
@@ -31,7 +34,7 @@ module Ci
raise
Gitlab
::
Access
::
AccessDeniedError
raise
Gitlab
::
Access
::
AccessDeniedError
end
end
attributes
=
CLONE_A
TTRIBUTE
S
.
map
do
|
attribute
|
attributes
=
CLONE_A
CCESSOR
S
.
map
do
|
attribute
|
[
attribute
,
build
.
send
(
attribute
)]
[
attribute
,
build
.
send
(
attribute
)]
end
end
...
...
spec/factories/ci/builds.rb
View file @
dd9d8ce8
...
@@ -76,6 +76,10 @@ FactoryGirl.define do
...
@@ -76,6 +76,10 @@ FactoryGirl.define do
manual
manual
end
end
trait
:tags
do
tag_list
[
:docker
,
:ruby
]
end
after
(
:build
)
do
|
build
,
evaluator
|
after
(
:build
)
do
|
build
,
evaluator
|
build
.
project
=
build
.
pipeline
.
project
build
.
project
=
build
.
pipeline
.
project
end
end
...
...
spec/services/ci/retry_build_service_spec.rb
View file @
dd9d8ce8
...
@@ -13,11 +13,11 @@ describe Ci::RetryBuildService, :services do
...
@@ -13,11 +13,11 @@ describe Ci::RetryBuildService, :services do
shared_examples
'build duplication'
do
shared_examples
'build duplication'
do
let
(
:build
)
do
let
(
:build
)
do
create
(
:ci_build
,
:failed
,
:artifacts_expired
,
:erased
,
:trace
,
create
(
:ci_build
,
:failed
,
:artifacts_expired
,
:erased
,
:trace
,
:queued
,
:coverage
,
pipeline:
pipeline
)
:queued
,
:coverage
,
:tags
,
pipeline:
pipeline
)
end
end
describe
'clone attributes'
do
describe
'clone attributes'
do
described_class
::
CLONE_A
TTRIBUTE
S
.
each
do
|
attribute
|
described_class
::
CLONE_A
CCESSOR
S
.
each
do
|
attribute
|
it
"clones
#{
attribute
}
build attribute"
do
it
"clones
#{
attribute
}
build attribute"
do
expect
(
new_build
.
send
(
attribute
)).
to
eq
build
.
send
(
attribute
)
expect
(
new_build
.
send
(
attribute
)).
to
eq
build
.
send
(
attribute
)
end
end
...
@@ -25,7 +25,7 @@ describe Ci::RetryBuildService, :services do
...
@@ -25,7 +25,7 @@ describe Ci::RetryBuildService, :services do
end
end
describe
'reject attributes'
do
describe
'reject attributes'
do
described_class
::
REJECT_A
TTRIBUTE
S
.
each
do
|
attribute
|
described_class
::
REJECT_A
CCESSOR
S
.
each
do
|
attribute
|
it
"does not clone
#{
attribute
}
build attribute"
do
it
"does not clone
#{
attribute
}
build attribute"
do
expect
(
new_build
.
send
(
attribute
)).
not_to
eq
build
.
send
(
attribute
)
expect
(
new_build
.
send
(
attribute
)).
not_to
eq
build
.
send
(
attribute
)
end
end
...
@@ -33,12 +33,23 @@ describe Ci::RetryBuildService, :services do
...
@@ -33,12 +33,23 @@ describe Ci::RetryBuildService, :services do
end
end
it
'has correct number of known attributes'
do
it
'has correct number of known attributes'
do
attributes
=
known_accessors
=
described_class
::
CLONE_ATTRIBUTES
+
described_class
::
CLONE_ACCESSORS
+
described_class
::
IGNORE_ATTRIBUTES
+
described_class
::
IGNORE_ACCESSORS
+
described_class
::
REJECT_ATTRIBUTES
described_class
::
REJECT_ACCESSORS
expect
(
build
.
attributes
.
size
).
to
eq
(
attributes
.
size
)
# :tag_list is a special case, this accessor does not exist
# in reflected associations, comes from `act_as_taggable` and
# we use it to copy tags, instead of reusing tags.
#
current_accessors
=
build
.
attribute_names
.
map
.
map
(
&
:to_sym
)
+
build
.
_reflections
.
map
{
|
assoc
|
assoc
.
first
.
to_sym
}
+
[
:tag_list
]
current_accessors
.
uniq!
expect
(
known_accessors
).
to
contain_exactly
(
*
current_accessors
)
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