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
b73f9d39
Commit
b73f9d39
authored
Dec 02, 2021
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy manual variables when retrying job
Copies manual variables when retrying a job. Changelog: fixed
parent
18fc6343
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
2 deletions
+49
-2
app/models/ci/build.rb
app/models/ci/build.rb
+10
-0
app/services/ci/retry_build_service.rb
app/services/ci/retry_build_service.rb
+7
-1
config/feature_flags/development/clone_job_variables_at_job_retry.yml
...re_flags/development/clone_job_variables_at_job_retry.yml
+8
-0
spec/services/ci/retry_build_service_spec.rb
spec/services/ci/retry_build_service_spec.rb
+24
-1
No files found.
app/models/ci/build.rb
View file @
b73f9d39
...
...
@@ -1084,6 +1084,16 @@ module Ci
runner
&
.
instance_type?
end
def
job_variables_attributes
strong_memoize
(
:job_variables_attributes
)
do
job_variables
.
internal_source
.
map
do
|
variable
|
variable
.
attributes
.
except
(
'id'
,
'job_id'
,
'encrypted_value'
,
'encrypted_value_iv'
).
tap
do
|
attrs
|
attrs
[
:value
]
=
variable
.
value
end
end
end
end
protected
def
run_status_commit_hooks!
...
...
app/services/ci/retry_build_service.rb
View file @
b73f9d39
...
...
@@ -68,7 +68,13 @@ module Ci
end
def
build_attributes
(
build
)
attributes
=
self
.
class
.
clone_accessors
.
to_h
do
|
attribute
|
clone_attributes
=
if
::
Feature
.
enabled?
(
:clone_job_variables_at_job_retry
,
build
.
project
,
default_enabled: :yaml
)
self
.
class
.
clone_accessors
+
[
:job_variables_attributes
]
else
self
.
class
.
clone_accessors
end
attributes
=
clone_attributes
.
to_h
do
|
attribute
|
[
attribute
,
build
.
public_send
(
attribute
)]
# rubocop:disable GitlabSecurity/PublicSend
end
...
...
config/feature_flags/development/clone_job_variables_at_job_retry.yml
0 → 100644
View file @
b73f9d39
---
name
:
clone_job_variables_at_job_retry
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75720
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/347156
milestone
:
'
14.6'
type
:
development
group
:
group::pipeline authoring
default_enabled
:
false
spec/services/ci/retry_build_service_spec.rb
View file @
b73f9d39
...
...
@@ -73,6 +73,8 @@ RSpec.describe Ci::RetryBuildService do
scheduled_at:
10
.
seconds
.
since
)
end
let_it_be
(
:internal_job_variable
)
{
create
(
:ci_job_variable
,
job:
build
)
}
before_all
do
# Make sure that build has both `stage_id` and `stage` because FactoryBot
# can reset one of the fields when assigning another. We plan to deprecate
...
...
@@ -86,7 +88,7 @@ RSpec.describe Ci::RetryBuildService do
file_type:
file_type
,
job:
build
,
expire_at:
build
.
artifacts_expire_at
)
end
create
(
:ci_job_variable
,
job:
build
)
create
(
:ci_job_variable
,
:dotenv_source
,
job:
build
)
create
(
:ci_build_need
,
build:
build
)
create
(
:terraform_state_version
,
build:
build
)
end
...
...
@@ -125,6 +127,27 @@ RSpec.describe Ci::RetryBuildService do
expect
(
new_build
.
needs_attributes
).
to
match
(
build
.
needs_attributes
)
expect
(
new_build
.
needs
).
not_to
match
(
build
.
needs
)
end
context
'when clone_job_variables_at_job_retry is enabled'
do
before
do
stub_feature_flags
(
clone_job_variables_at_job_retry:
true
)
end
it
'clones only internal job variables'
do
expect
(
new_build
.
job_variables
.
count
).
to
eq
(
1
)
expect
(
new_build
.
job_variables
).
to
contain_exactly
(
having_attributes
(
key:
internal_job_variable
.
key
,
value:
internal_job_variable
.
value
))
end
end
context
'when clone_job_variables_at_job_retry is not enabled'
do
before
do
stub_feature_flags
(
clone_job_variables_at_job_retry:
false
)
end
it
'does not clones internal job variables'
do
expect
(
new_build
.
job_variables
.
count
).
to
eq
(
0
)
end
end
end
describe
'reject accessors'
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