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
6013768f
Commit
6013768f
authored
Jun 10, 2016
by
Kamil Trzcinski
Committed by
Phil Hughes
Jun 13, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added keep artifacts API endpoint
parent
7e9273dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
0 deletions
+96
-0
doc/api/builds.md
doc/api/builds.md
+50
-0
lib/api/builds.rb
lib/api/builds.rb
+19
-0
spec/requests/api/builds_spec.rb
spec/requests/api/builds_spec.rb
+27
-0
No files found.
doc/api/builds.md
View file @
6013768f
...
...
@@ -443,3 +443,53 @@ Example of response
"user"
:
null
}
```
## Keep artifacts
Prevents artifacts from being deleted when expiration is set
```
POST /projects/:id/builds/:build_id/artifacts/keep
```
Parameters
| Attribute | Type | required | Description |
|-------------|---------|----------|---------------------|
|
`id`
| integer | yes | The ID of a project |
|
`build_id`
| integer | yes | The ID of a build |
Example of request
```
curl -X POST -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/1/builds/1/artifacts/keep"
```
Example of response
```
json
{
"commit"
:
{
"author_email"
:
"admin@example.com"
,
"author_name"
:
"Administrator"
,
"created_at"
:
"2015-12-24T16:51:14.000+01:00"
,
"id"
:
"0ff3ae198f8601a285adcf5c0fff204ee6fba5fd"
,
"message"
:
"Test the CI integration."
,
"short_id"
:
"0ff3ae19"
,
"title"
:
"Test the CI integration."
},
"coverage"
:
null
,
"download_url"
:
null
,
"id"
:
69
,
"name"
:
"rubocop"
,
"ref"
:
"master"
,
"runner"
:
null
,
"stage"
:
"test"
,
"created_at"
:
"2016-01-11T10:13:33.506Z"
,
"started_at"
:
"2016-01-11T10:13:33.506Z"
,
"finished_at"
:
"2016-01-11T10:15:10.506Z"
,
"status"
:
"failed"
,
"tag"
:
false
,
"user"
:
null
}
```
lib/api/builds.rb
View file @
6013768f
...
...
@@ -166,6 +166,25 @@ module API
present
build
,
with:
Entities
::
Build
,
user_can_download_artifacts:
can?
(
current_user
,
:download_build_artifacts
,
user_project
)
end
# Keep the artifacts to prevent them to be deleted
#
# Parameters:
# id (required) - The ID of a build
# Example Request:
# POST /projects/:id/builds/:build_id/artifacts/keep
post
':id/builds/:build_id/artifacts/keep'
do
authorize_update_builds!
build
=
get_build
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
&&
build
.
artifacts?
build
.
keep_artifacts!
status
200
present
build
,
with:
Entities
::
Build
,
user_can_download_artifacts:
can?
(
current_user
,
:read_build
,
user_project
)
end
end
helpers
do
...
...
spec/requests/api/builds_spec.rb
View file @
6013768f
...
...
@@ -241,4 +241,31 @@ describe API::API, api: true do
end
end
end
describe
'POST /projects/:id/builds/:build_id/artifacts/keep'
do
before
do
post
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/artifacts/keep"
,
user
)
end
context
'artifacts did not expire'
do
let
(
:build
)
do
create
(
:ci_build
,
:trace
,
:artifacts
,
:success
,
project:
project
,
pipeline:
pipeline
,
artifacts_expire_at:
Time
.
now
+
7
.
days
)
end
it
'should keep artifacts'
do
expect
(
response
.
status
).
to
eq
200
build
.
reload
expect
(
build
.
artifacts_expire_at
).
to
be_nil
end
end
context
'no artifacts'
do
let
(
:build
)
{
create
(
:ci_build
,
project:
project
,
pipeline:
pipeline
)
}
it
'should respond with not found'
do
expect
(
response
.
status
).
to
eq
404
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