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
920e4db3
Commit
920e4db3
authored
Jun 17, 2020
by
Vladimir Shushlin
Committed by
Oswaldo Ferreira
Jun 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep build artifacts referenced by the release evidence
These artifacts need to be preserved for audit purposes
parent
42109dd9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
7 deletions
+93
-7
app/models/ci/build.rb
app/models/ci/build.rb
+5
-0
ee/app/services/ee/releases/create_evidence_service.rb
ee/app/services/ee/releases/create_evidence_service.rb
+15
-7
ee/changelogs/unreleased/32773-include-test-results-within-release-evidence-2.yml
.../32773-include-test-results-within-release-evidence-2.yml
+5
-0
ee/spec/services/ee/releases/create_evidence_service_spec.rb
ee/spec/services/ee/releases/create_evidence_service_spec.rb
+24
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+44
-0
No files found.
app/models/ci/build.rb
View file @
920e4db3
...
...
@@ -801,6 +801,11 @@ module Ci
has_expiring_artifacts?
&&
job_artifacts_archive
.
present?
end
def
self
.
keep_artifacts!
update_all
(
artifacts_expire_at:
nil
)
Ci
::
JobArtifact
.
where
(
job:
self
.
select
(
:id
)).
update_all
(
expire_at:
nil
)
end
def
keep_artifacts!
self
.
update
(
artifacts_expire_at:
nil
)
self
.
job_artifacts
.
update_all
(
expire_at:
nil
)
...
...
ee/app/services/ee/releases/create_evidence_service.rb
View file @
920e4db3
...
...
@@ -5,19 +5,27 @@ module EE
module
CreateEvidenceService
extend
::
Gitlab
::
Utils
::
Override
override
:evidence_options
def
evidence_options
options
=
super
.
dup
def
execute
super
if
release
.
project
.
feature_available?
(
:release_evidence_test_artifacts
)
options
[
:report_artifacts
]
=
report_artifacts
keep_report_artifacts
end
options
override
:evidence_options
def
evidence_options
super
.
merge
(
report_artifacts:
report_artifacts
)
end
def
report_artifacts
pipeline
&
.
latest_report_builds
||
[]
return
::
Ci
::
Build
.
none
unless
release
.
project
.
feature_available?
(
:release_evidence_test_artifacts
)
pipeline
&
.
latest_report_builds
||
::
Ci
::
Build
.
none
end
def
keep_report_artifacts
report_artifacts
.
keep_artifacts!
end
end
end
...
...
ee/changelogs/unreleased/32773-include-test-results-within-release-evidence-2.yml
0 → 100644
View file @
920e4db3
---
title
:
Keep artifacts referenced by release evidence
merge_request
:
29350
author
:
type
:
added
ee/spec/services/ee/releases/create_evidence_service_spec.rb
View file @
920e4db3
...
...
@@ -39,5 +39,29 @@ describe Releases::CreateEvidenceService do
service
.
execute
expect
(
Releases
::
Evidence
.
last
.
summary
[
'release'
]).
not_to
have_key
(
'report_artifacts'
)
end
it
'keeps build report artifacts if feature is licenced'
do
stub_licensed_features
(
release_evidence_test_artifacts:
true
)
Ci
::
Build
.
update_all
(
artifacts_expire_at:
1
.
month
.
from_now
)
service
.
execute
expect
(
build_with_artifacts
.
reload
.
artifacts_expire_at
).
to
be_present
expect
(
build_test_report
.
reload
.
artifacts_expire_at
).
to
be_nil
expect
(
build_coverage_report
.
reload
.
artifacts_expire_at
).
to
be_nil
end
it
'does not keep artifacts if feature is unlicenced'
do
stub_licensed_features
(
release_evidence_test_artifacts:
false
)
Ci
::
Build
.
update_all
(
artifacts_expire_at:
1
.
month
.
from_now
)
service
.
execute
expect
(
build_with_artifacts
.
reload
.
artifacts_expire_at
).
to
be_present
expect
(
build_test_report
.
reload
.
artifacts_expire_at
).
to
be_present
expect
(
build_coverage_report
.
reload
.
artifacts_expire_at
).
to
be_present
end
end
end
spec/models/ci/build_spec.rb
View file @
920e4db3
...
...
@@ -1811,6 +1811,50 @@ describe Ci::Build do
end
end
describe
'.keep_artifacts!'
do
let!
(
:build
)
{
create
(
:ci_build
,
artifacts_expire_at:
Time
.
current
+
7
.
days
)
}
let!
(
:builds_for_update
)
do
Ci
::
Build
.
where
(
id:
create_list
(
:ci_build
,
3
,
artifacts_expire_at:
Time
.
current
+
7
.
days
).
map
(
&
:id
))
end
it
'resets expire_at'
do
builds_for_update
.
keep_artifacts!
builds_for_update
.
each
do
|
build
|
expect
(
build
.
reload
.
artifacts_expire_at
).
to
be_nil
end
end
it
'does not reset expire_at for other builds'
do
builds_for_update
.
keep_artifacts!
expect
(
build
.
reload
.
artifacts_expire_at
).
to
be_present
end
context
'when having artifacts files'
do
let!
(
:artifact
)
{
create
(
:ci_job_artifact
,
job:
build
,
expire_in:
'7 days'
)
}
let!
(
:artifacts_for_update
)
do
builds_for_update
.
map
do
|
build
|
create
(
:ci_job_artifact
,
job:
build
,
expire_in:
'7 days'
)
end
end
it
'resets dependent objects'
do
builds_for_update
.
keep_artifacts!
artifacts_for_update
.
each
do
|
artifact
|
expect
(
artifact
.
reload
.
expire_at
).
to
be_nil
end
end
it
'does not reset dependent object for other builds'
do
builds_for_update
.
keep_artifacts!
expect
(
artifact
.
reload
.
expire_at
).
to
be_present
end
end
end
describe
'#keep_artifacts!'
do
let
(
:build
)
{
create
(
:ci_build
,
artifacts_expire_at:
Time
.
current
+
7
.
days
)
}
...
...
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