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
4db83367
Commit
4db83367
authored
Mar 06, 2019
by
Roger Rüttimann
Committed by
Kamil Trzciński
Mar 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: delete job_artifacts of a single job
parent
79305b77
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
118 additions
and
22 deletions
+118
-22
app/policies/project_policy.rb
app/policies/project_policy.rb
+1
-0
changelogs/unreleased/feature-api-delete-job-artifacts.yml
changelogs/unreleased/feature-api-delete-job-artifacts.yml
+5
-0
doc/api/jobs.md
doc/api/jobs.md
+49
-22
lib/api/helpers.rb
lib/api/helpers.rb
+4
-0
lib/api/job_artifacts.rb
lib/api/job_artifacts.rb
+16
-0
spec/requests/api/jobs_spec.rb
spec/requests/api/jobs_spec.rb
+43
-0
No files found.
app/policies/project_policy.rb
View file @
4db83367
...
...
@@ -278,6 +278,7 @@ class ProjectPolicy < BasePolicy
enable
:admin_cluster
enable
:create_environment_terminal
enable
:destroy_release
enable
:destroy_artifacts
enable
:daily_statistics
end
...
...
changelogs/unreleased/feature-api-delete-job-artifacts.yml
0 → 100644
View file @
4db83367
---
title
:
Extend the Gitlab API for deletion of job_artifacts of a single job.
merge_request
:
25522
author
:
rroger
type
:
added
doc/api/jobs.md
View file @
4db83367
This diff is collapsed.
Click to expand it.
lib/api/helpers.rb
View file @
4db83367
...
...
@@ -244,6 +244,10 @@ module API
authorize!
:read_build
,
user_project
end
def
authorize_destroy_artifacts!
authorize!
:destroy_artifacts
,
user_project
end
def
authorize_update_builds!
authorize!
:update_build
,
user_project
end
...
...
lib/api/job_artifacts.rb
View file @
4db83367
...
...
@@ -109,6 +109,22 @@ module API
status
200
present
build
,
with:
Entities
::
Job
end
desc
'Delete the artifacts files from a job'
do
detail
'This feature was introduced in GitLab 11.9'
end
params
do
requires
:job_id
,
type:
Integer
,
desc:
'The ID of a job'
end
delete
':id/jobs/:job_id/artifacts'
do
authorize_destroy_artifacts!
build
=
find_build!
(
params
[
:job_id
])
authorize!
(
:destroy_artifacts
,
build
)
build
.
erase_erasable_artifacts!
status
:no_content
end
end
end
end
spec/requests/api/jobs_spec.rb
View file @
4db83367
...
...
@@ -321,6 +321,49 @@ describe API::Jobs do
end
end
describe
'DELETE /projects/:id/jobs/:job_id/artifacts'
do
let!
(
:job
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
,
user:
api_user
)
}
before
do
delete
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/artifacts"
,
api_user
)
end
context
'when user is anonymous'
do
let
(
:api_user
)
{
nil
}
it
'does not delete artifacts'
do
expect
(
job
.
job_artifacts
.
size
).
to
eq
2
end
it
'returns status 401 (unauthorized)'
do
expect
(
response
).
to
have_http_status
:unauthorized
end
end
context
'with developer'
do
it
'does not delete artifacts'
do
expect
(
job
.
job_artifacts
.
size
).
to
eq
2
end
it
'returns status 403 (forbidden)'
do
expect
(
response
).
to
have_http_status
:forbidden
end
end
context
'with authorized user'
do
let
(
:maintainer
)
{
create
(
:project_member
,
:maintainer
,
project:
project
).
user
}
let!
(
:api_user
)
{
maintainer
}
it
'deletes artifacts'
do
expect
(
job
.
job_artifacts
.
size
).
to
eq
0
end
it
'returns status 204 (no content)'
do
expect
(
response
).
to
have_http_status
:no_content
end
end
end
describe
'GET /projects/:id/jobs/:job_id/artifacts/:artifact_path'
do
context
'when job has artifacts'
do
let
(
:job
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
...
...
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