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
iv
gitlab-ce
Commits
13f92521
Commit
13f92521
authored
Feb 03, 2016
by
Grzegorz Bizon
Committed by
Grzegorz Bizon
Feb 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move build eraseable API to proper API context
parent
a2eac468
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
31 deletions
+47
-31
lib/api/builds.rb
lib/api/builds.rb
+21
-1
lib/ci/api/builds.rb
lib/ci/api/builds.rb
+1
-18
spec/requests/api/builds_spec.rb
spec/requests/api/builds_spec.rb
+25
-0
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+0
-12
No files found.
lib/api/builds.rb
View file @
13f92521
...
@@ -115,13 +115,33 @@ module API
...
@@ -115,13 +115,33 @@ module API
authorize_update_builds!
authorize_update_builds!
build
=
get_build
(
params
[
:build_id
])
build
=
get_build
(
params
[
:build_id
])
return
forbidden!
(
'Build is not retryable'
)
unless
build
&&
build
.
retryable?
return
not_found!
(
build
)
unless
build
return
forbidden!
(
'Build is not retryable'
)
unless
build
.
retryable?
build
=
Ci
::
Build
.
retry
(
build
)
build
=
Ci
::
Build
.
retry
(
build
)
present
build
,
with:
Entities
::
Build
,
present
build
,
with:
Entities
::
Build
,
user_can_download_artifacts:
can?
(
current_user
,
:read_build
,
user_project
)
user_can_download_artifacts:
can?
(
current_user
,
:read_build
,
user_project
)
end
end
# Erase build (remove artifacts and build trace)
#
# Parameters:
# id (required) - the id of a project
# build_id (required) - the id of a build
# example Request:
# delete /projects/:id/build/:build_id/content
delete
':id/builds/:build_id/content'
do
authorize_manage_builds!
build
=
get_build
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
return
forbidden!
(
'Build is not eraseable!'
)
unless
build
.
eraseable?
build
.
erase!
present
build
,
with:
Entities
::
Build
,
user_can_download_artifacts:
can?
(
current_user
,
:download_build_artifacts
,
user_project
)
end
end
end
helpers
do
helpers
do
...
...
lib/ci/api/builds.rb
View file @
13f92521
...
@@ -146,7 +146,7 @@ module Ci
...
@@ -146,7 +146,7 @@ module Ci
present_file!
(
artifacts_file
.
path
,
artifacts_file
.
filename
)
present_file!
(
artifacts_file
.
path
,
artifacts_file
.
filename
)
end
end
# Remove the artifacts file from build
# Remove the artifacts file from build
- Runners only
#
#
# Parameters:
# Parameters:
# id (required) - The ID of a build
# id (required) - The ID of a build
...
@@ -163,23 +163,6 @@ module Ci
...
@@ -163,23 +163,6 @@ module Ci
build
.
remove_artifacts_file!
build
.
remove_artifacts_file!
build
.
remove_artifacts_metadata!
build
.
remove_artifacts_metadata!
end
end
# Erase build (remove artifacts and build trace)
#
# Parameters:
# id (required) - The ID of a build
# token (required) - The build authorization token
# Headers:
# BUILD-TOKEN (required) - The build authorization token, the same as token
# Example Request:
# DELETE /builds/:id/content
delete
':id/content'
do
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
not_found!
unless
build
authenticate_build_token!
(
build
)
build
.
erase!
end
end
end
end
end
end
end
...
...
spec/requests/api/builds_spec.rb
View file @
13f92521
...
@@ -169,4 +169,29 @@ describe API::API, api: true do
...
@@ -169,4 +169,29 @@ describe API::API, api: true do
end
end
end
end
end
end
describe
'DELETE /projects/:id/builds/:build_id/content'
do
before
do
delete
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/content"
,
user
)
end
context
'build is eraseable'
do
let
(
:build
)
{
create
(
:ci_build_with_trace
,
:artifacts
,
:success
,
project:
project
,
commit:
commit
)
}
it
'should erase build content'
do
expect
(
response
.
status
).
to
eq
200
expect
(
build
.
trace
).
to
be_empty
expect
(
build
.
artifacts_file
.
exists?
).
to
be_falsy
expect
(
build
.
artifacts_metadata
.
exists?
).
to
be_falsy
end
end
context
'build is not eraseable'
do
let
(
:build
)
{
create
(
:ci_build_with_trace
,
project:
project
,
commit:
commit
)
}
it
'should respond with forbidden'
do
expect
(
response
.
status
).
to
eq
403
end
end
end
end
end
spec/requests/ci/api/builds_spec.rb
View file @
13f92521
...
@@ -156,18 +156,6 @@ describe Ci::API::API do
...
@@ -156,18 +156,6 @@ describe Ci::API::API do
end
end
end
end
describe
'DELETE /builds/:id/content'
do
let
(
:build
)
{
create
(
:ci_build_with_trace
,
:artifacts
,
:success
)
}
before
{
delete
ci_api
(
"/builds/
#{
build
.
id
}
/content"
),
token:
build
.
token
}
it
'should erase build content'
do
expect
(
response
.
status
).
to
eq
200
expect
(
build
.
trace
).
to
be_empty
expect
(
build
.
artifacts_file
.
exists?
).
to
be_falsy
expect
(
build
.
artifacts_metadata
.
exists?
).
to
be_falsy
end
end
context
"Artifacts"
do
context
"Artifacts"
do
let
(
:file_upload
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
}
let
(
:file_upload
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
}
let
(
:file_upload2
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/gif'
)
}
let
(
:file_upload2
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/gif'
)
}
...
...
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