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
Jérome Perrin
gitlab-ce
Commits
fffe5c2b
Commit
fffe5c2b
authored
Aug 15, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Play endpoints on Builds
parent
15b441f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
0 deletions
+46
-0
CHANGELOG
CHANGELOG
+1
-0
lib/api/builds.rb
lib/api/builds.rb
+23
-0
spec/requests/api/builds_spec.rb
spec/requests/api/builds_spec.rb
+22
-0
No files found.
CHANGELOG
View file @
fffe5c2b
...
...
@@ -30,6 +30,7 @@ v 8.11.0 (unreleased)
- Expand commit message width in repo view (ClemMakesApps)
- Cache highlighted diff lines for merge requests
- Pre-create all builds for a Pipeline when the new Pipeline is created !5295
- Add Play endpoint on Builds
- Fix of 'Commits being passed to custom hooks are already reachable when using the UI'
- Show member roles to all users on members page
- Project.visible_to_user is instrumented again
...
...
lib/api/builds.rb
View file @
fffe5c2b
...
...
@@ -189,6 +189,29 @@ module API
present
build
,
with:
Entities
::
Build
,
user_can_download_artifacts:
can?
(
current_user
,
:read_build
,
user_project
)
end
desc
'Trigger a manual build'
do
success
Entities
::
Build
detail
'This feature was added in GitLab 8.11'
end
params
do
requires
:build_id
,
type:
Integer
,
desc:
'The ID of a Build'
end
post
":id/builds/:build_id/play"
do
authorize_read_builds!
build
=
get_build!
(
params
[
:build_id
])
if
build
.
playable?
build
.
play
(
current_user
)
status
200
present
build
,
with:
Entities
::
Build
,
user_can_download_artifacts:
can?
(
current_user
,
:read_build
,
user_project
)
else
bad_request!
(
"Unplayable Build"
)
end
end
end
helpers
do
...
...
spec/requests/api/builds_spec.rb
View file @
fffe5c2b
...
...
@@ -407,4 +407,26 @@ describe API::API, api: true do
end
end
end
describe
'POST /projects/:id/builds/:build_id/play'
do
before
do
post
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/play"
,
user
)
end
context
'on an playable build'
do
let
(
:build
)
{
create
(
:ci_build
,
:manual
,
project:
project
,
pipeline:
pipeline
)
}
it
'plays the build'
do
expect
(
response
).
to
have_http_status
200
expect
(
json_response
[
'user'
][
'id'
]).
to
eq
(
user
.
id
)
end
end
context
'on a non-playable build'
do
it
'returns a status code 400, Bad Request'
do
expect
(
response
).
to
have_http_status
400
expect
(
response
.
body
).
to
match
(
"Unplayable Build"
)
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