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
Léo-Paul Géneau
gitlab-ce
Commits
421be01d
Commit
421be01d
authored
Jun 10, 2016
by
Kamil Trzcinski
Committed by
Phil Hughes
Jun 13, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve design based on review
parent
9281709b
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
296 additions
and
292 deletions
+296
-292
app/models/ci/build.rb
app/models/ci/build.rb
+4
-5
doc/api/builds.md
doc/api/builds.md
+264
-264
lib/api/builds.rb
lib/api/builds.rb
+3
-2
lib/ci/api/entities.rb
lib/ci/api/entities.rb
+2
-2
spec/features/builds_spec.rb
spec/features/builds_spec.rb
+3
-5
spec/models/build_spec.rb
spec/models/build_spec.rb
+3
-0
spec/requests/api/builds_spec.rb
spec/requests/api/builds_spec.rb
+3
-4
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+3
-3
spec/workers/expire_build_artifacts_worker_spec.rb
spec/workers/expire_build_artifacts_worker_spec.rb
+11
-7
No files found.
app/models/ci/build.rb
View file @
421be01d
...
@@ -360,10 +360,9 @@ module Ci
...
@@ -360,10 +360,9 @@ module Ci
end
end
def
artifacts_expire_in
=
(
value
)
def
artifacts_expire_in
=
(
value
)
self
.
artifacts_expire_at
=
if
value
if
value
self
.
artifacts_expire_at
=
Time
.
now
+
ChronicDuration
.
parse
(
value
)
Time
.
now
+
ChronicDuration
.
parse
(
value
)
else
self
.
artifacts_expire_at
=
nil
end
end
end
end
...
...
doc/api/builds.md
View file @
421be01d
...
@@ -446,7 +446,7 @@ Example of response
...
@@ -446,7 +446,7 @@ Example of response
## Keep artifacts
## Keep artifacts
Prevents artifacts from being deleted when expiration is set
Prevents artifacts from being deleted when expiration is set
.
```
```
POST /projects/:id/builds/:build_id/artifacts/keep
POST /projects/:id/builds/:build_id/artifacts/keep
...
@@ -459,13 +459,13 @@ Parameters
...
@@ -459,13 +459,13 @@ Parameters
|
`id`
| integer | yes | The ID of a project |
|
`id`
| integer | yes | The ID of a project |
|
`build_id`
| integer | yes | The ID of a build |
|
`build_id`
| integer | yes | The ID of a build |
Example
of request
Example
request:
```
```
curl -X POST -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/artifacts/keep"
curl -X POST -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/artifacts/keep"
```
```
Example
of response
Example
response:
```
json
```
json
{
{
...
...
lib/api/builds.rb
View file @
421be01d
...
@@ -167,10 +167,11 @@ module API
...
@@ -167,10 +167,11 @@ module API
user_can_download_artifacts:
can?
(
current_user
,
:download_build_artifacts
,
user_project
)
user_can_download_artifacts:
can?
(
current_user
,
:download_build_artifacts
,
user_project
)
end
end
# Keep the artifacts to prevent them
to be
deleted
# Keep the artifacts to prevent them
from being
deleted
#
#
# Parameters:
# Parameters:
# id (required) - The ID of a build
# id (required) - the id of a project
# build_id (required) - The ID of a build
# Example Request:
# Example Request:
# POST /projects/:id/builds/:build_id/artifacts/keep
# POST /projects/:id/builds/:build_id/artifacts/keep
post
':id/builds/:build_id/artifacts/keep'
do
post
':id/builds/:build_id/artifacts/keep'
do
...
...
lib/ci/api/entities.rb
View file @
421be01d
...
@@ -20,7 +20,7 @@ module Ci
...
@@ -20,7 +20,7 @@ module Ci
expose
:name
,
:token
,
:stage
expose
:name
,
:token
,
:stage
expose
:project_id
expose
:project_id
expose
:project_name
expose
:project_name
expose
:artifacts_file
,
using:
ArtifactFile
,
if:
lambda
{
|
build
,
opts
|
build
.
artifacts?
}
expose
:artifacts_file
,
using:
ArtifactFile
,
if:
->
(
build
,
_
)
{
build
.
artifacts?
}
end
end
class
BuildDetails
<
Build
class
BuildDetails
<
Build
...
@@ -29,7 +29,7 @@ module Ci
...
@@ -29,7 +29,7 @@ module Ci
expose
:before_sha
expose
:before_sha
expose
:allow_git_fetch
expose
:allow_git_fetch
expose
:token
expose
:token
expose
:artifacts_expire_at
,
if:
lambda
{
|
build
,
opts
|
build
.
artifacts?
}
expose
:artifacts_expire_at
,
if:
->
(
build
,
_
)
{
build
.
artifacts?
}
expose
:options
do
|
model
|
expose
:options
do
|
model
|
model
.
options
model
.
options
...
...
spec/features/builds_spec.rb
View file @
421be01d
...
@@ -106,7 +106,7 @@ describe "Builds" do
...
@@ -106,7 +106,7 @@ describe "Builds" do
context
'no expire date defined'
do
context
'no expire date defined'
do
let
(
:expire_at
)
{
nil
}
let
(
:expire_at
)
{
nil
}
it
'
should
not have the Keep button'
do
it
'
does
not have the Keep button'
do
page
.
within
(
'.artifacts'
)
do
page
.
within
(
'.artifacts'
)
do
expect
(
page
).
not_to
have_content
'Keep'
expect
(
page
).
not_to
have_content
'Keep'
end
end
...
@@ -116,7 +116,7 @@ describe "Builds" do
...
@@ -116,7 +116,7 @@ describe "Builds" do
context
'when expire date is defined'
do
context
'when expire date is defined'
do
let
(
:expire_at
)
{
Time
.
now
+
7
.
days
}
let
(
:expire_at
)
{
Time
.
now
+
7
.
days
}
it
'
should keep
artifacts when Keep button is clicked'
do
it
'
keeps
artifacts when Keep button is clicked'
do
page
.
within
(
'.artifacts'
)
do
page
.
within
(
'.artifacts'
)
do
expect
(
page
).
to
have_content
'The artifacts will be removed'
expect
(
page
).
to
have_content
'The artifacts will be removed'
click_link
'Keep'
click_link
'Keep'
...
@@ -130,7 +130,7 @@ describe "Builds" do
...
@@ -130,7 +130,7 @@ describe "Builds" do
context
'when artifacts expired'
do
context
'when artifacts expired'
do
let
(
:expire_at
)
{
Time
.
now
-
7
.
days
}
let
(
:expire_at
)
{
Time
.
now
-
7
.
days
}
it
'
should
not have the Keep button'
do
it
'
does
not have the Keep button'
do
page
.
within
(
'.artifacts'
)
do
page
.
within
(
'.artifacts'
)
do
expect
(
page
).
to
have_content
'The artifacts were removed'
expect
(
page
).
to
have_content
'The artifacts were removed'
expect
(
page
).
not_to
have_link
'Keep'
expect
(
page
).
not_to
have_link
'Keep'
...
@@ -150,8 +150,6 @@ describe "Builds" do
...
@@ -150,8 +150,6 @@ describe "Builds" do
expect
(
page
).
to
have_link
'Raw'
expect
(
page
).
to
have_link
'Raw'
end
end
end
end
context
''
end
end
describe
"POST /:project/builds/:id/cancel"
do
describe
"POST /:project/builds/:id/cancel"
do
...
...
spec/models/build_spec.rb
View file @
421be01d
...
@@ -467,6 +467,7 @@ describe Ci::Build, models: true do
...
@@ -467,6 +467,7 @@ describe Ci::Build, models: true do
it
'when assigning valid duration'
do
it
'when assigning valid duration'
do
build
.
artifacts_expire_in
=
'7 days'
build
.
artifacts_expire_in
=
'7 days'
is_expected
.
to
be_within
(
10
).
of
(
7
.
days
.
to_i
)
is_expected
.
to
be_within
(
10
).
of
(
7
.
days
.
to_i
)
end
end
...
@@ -477,6 +478,7 @@ describe Ci::Build, models: true do
...
@@ -477,6 +478,7 @@ describe Ci::Build, models: true do
it
'when resseting value'
do
it
'when resseting value'
do
build
.
artifacts_expire_in
=
nil
build
.
artifacts_expire_in
=
nil
is_expected
.
to
be_nil
is_expected
.
to
be_nil
end
end
end
end
...
@@ -486,6 +488,7 @@ describe Ci::Build, models: true do
...
@@ -486,6 +488,7 @@ describe Ci::Build, models: true do
it
'to reset expire_at'
do
it
'to reset expire_at'
do
build
.
keep_artifacts!
build
.
keep_artifacts!
expect
(
build
.
artifacts_expire_at
).
to
be_nil
expect
(
build
.
artifacts_expire_at
).
to
be_nil
end
end
end
end
...
...
spec/requests/api/builds_spec.rb
View file @
421be01d
...
@@ -253,17 +253,16 @@ describe API::API, api: true do
...
@@ -253,17 +253,16 @@ describe API::API, api: true do
project:
project
,
pipeline:
pipeline
,
artifacts_expire_at:
Time
.
now
+
7
.
days
)
project:
project
,
pipeline:
pipeline
,
artifacts_expire_at:
Time
.
now
+
7
.
days
)
end
end
it
'
should keep
artifacts'
do
it
'
keeps
artifacts'
do
expect
(
response
.
status
).
to
eq
200
expect
(
response
.
status
).
to
eq
200
build
.
reload
expect
(
build
.
reload
.
artifacts_expire_at
).
to
be_nil
expect
(
build
.
artifacts_expire_at
).
to
be_nil
end
end
end
end
context
'no artifacts'
do
context
'no artifacts'
do
let
(
:build
)
{
create
(
:ci_build
,
project:
project
,
pipeline:
pipeline
)
}
let
(
:build
)
{
create
(
:ci_build
,
project:
project
,
pipeline:
pipeline
)
}
it
'
should respond
with not found'
do
it
'
responds
with not found'
do
expect
(
response
.
status
).
to
eq
404
expect
(
response
.
status
).
to
eq
404
end
end
end
end
...
...
spec/requests/ci/api/builds_spec.rb
View file @
421be01d
...
@@ -364,7 +364,7 @@ describe Ci::API::API do
...
@@ -364,7 +364,7 @@ describe Ci::API::API do
end
end
end
end
context
'expire date'
do
context
'
with an
expire date'
do
let!
(
:artifacts
)
{
file_upload
}
let!
(
:artifacts
)
{
file_upload
}
let
(
:post_data
)
do
let
(
:post_data
)
do
...
@@ -377,7 +377,7 @@ describe Ci::API::API do
...
@@ -377,7 +377,7 @@ describe Ci::API::API do
post
(
post_url
,
post_data
,
headers_with_token
)
post
(
post_url
,
post_data
,
headers_with_token
)
end
end
context
'
updates when specified
'
do
context
'
with an expire_in given
'
do
let
(
:expire_in
)
{
'7 days'
}
let
(
:expire_in
)
{
'7 days'
}
it
do
it
do
...
@@ -388,7 +388,7 @@ describe Ci::API::API do
...
@@ -388,7 +388,7 @@ describe Ci::API::API do
end
end
end
end
context
'
ignores if not specified
'
do
context
'
with no expire_in given
'
do
let
(
:expire_in
)
{
nil
}
let
(
:expire_in
)
{
nil
}
it
do
it
do
...
...
spec/workers/expire_build_artifacts_worker_spec.rb
View file @
421be01d
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
ExpireBuildArtifactsWorker
do
describe
ExpireBuildArtifactsWorker
do
include
RepoHelpers
include
RepoHelpers
let
(
:worker
)
{
ExpireBuildArtifactsWorker
.
new
}
let
(
:worker
)
{
described_class
.
new
}
describe
'#perform'
do
describe
'#perform'
do
context
'with expired artifacts'
do
context
'with expired artifacts'
do
...
@@ -11,9 +11,10 @@ describe ExpireBuildArtifactsWorker do
...
@@ -11,9 +11,10 @@ describe ExpireBuildArtifactsWorker do
it
do
it
do
expect_any_instance_of
(
Ci
::
Build
).
to
receive
(
:erase_artifacts!
)
expect_any_instance_of
(
Ci
::
Build
).
to
receive
(
:erase_artifacts!
)
worker
.
perform
worker
.
perform
build
.
reload
expect
(
build
.
artifacts_expired?
).
to
be_truthy
expect
(
build
.
reload
.
artifacts_expired?
).
to
be_truthy
end
end
end
end
...
@@ -22,9 +23,10 @@ describe ExpireBuildArtifactsWorker do
...
@@ -22,9 +23,10 @@ describe ExpireBuildArtifactsWorker do
it
do
it
do
expect_any_instance_of
(
Ci
::
Build
).
not_to
receive
(
:erase_artifacts!
)
expect_any_instance_of
(
Ci
::
Build
).
not_to
receive
(
:erase_artifacts!
)
worker
.
perform
worker
.
perform
build
.
reload
expect
(
build
.
artifacts_expired?
).
to
be_falsey
expect
(
build
.
reload
.
artifacts_expired?
).
to
be_falsey
end
end
end
end
...
@@ -33,6 +35,7 @@ describe ExpireBuildArtifactsWorker do
...
@@ -33,6 +35,7 @@ describe ExpireBuildArtifactsWorker do
it
do
it
do
expect_any_instance_of
(
Ci
::
Build
).
not_to
receive
(
:erase_artifacts!
)
expect_any_instance_of
(
Ci
::
Build
).
not_to
receive
(
:erase_artifacts!
)
worker
.
perform
worker
.
perform
end
end
end
end
...
@@ -47,9 +50,10 @@ describe ExpireBuildArtifactsWorker do
...
@@ -47,9 +50,10 @@ describe ExpireBuildArtifactsWorker do
it
do
it
do
expect_any_instance_of
(
Ci
::
Build
).
not_to
receive
(
:erase_artifacts!
)
expect_any_instance_of
(
Ci
::
Build
).
not_to
receive
(
:erase_artifacts!
)
worker
.
perform
worker
.
perform
build
.
reload
expect
(
build
.
artifacts_expired?
).
to
be_truthy
expect
(
build
.
reload
.
artifacts_expired?
).
to
be_truthy
end
end
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