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
1eb7b5ee
Commit
1eb7b5ee
authored
Jan 08, 2016
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify entities for builds API
parent
549a2fa7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
25 deletions
+29
-25
lib/api/builds.rb
lib/api/builds.rb
+11
-5
lib/api/entities.rb
lib/api/entities.rb
+18
-19
spec/requests/api/builds_spec.rb
spec/requests/api/builds_spec.rb
+0
-1
No files found.
lib/api/builds.rb
View file @
1eb7b5ee
...
@@ -15,7 +15,9 @@ module API
...
@@ -15,7 +15,9 @@ module API
get
':id/builds'
do
get
':id/builds'
do
builds
=
user_project
.
builds
.
order
(
'id DESC'
)
builds
=
user_project
.
builds
.
order
(
'id DESC'
)
builds
=
filter_builds
(
builds
,
params
[
:scope
])
builds
=
filter_builds
(
builds
,
params
[
:scope
])
present
paginate
(
builds
),
with:
Entities
::
Build
present
paginate
(
builds
),
with:
Entities
::
Build
,
user_can_download_artifacts:
can?
(
current_user
,
:download_build_artifacts
,
user_project
)
end
end
# Get builds for a specific commit of a project
# Get builds for a specific commit of a project
...
@@ -33,7 +35,8 @@ module API
...
@@ -33,7 +35,8 @@ module API
builds
=
commit
.
builds
.
order
(
'id DESC'
)
builds
=
commit
.
builds
.
order
(
'id DESC'
)
builds
=
filter_builds
(
builds
,
params
[
:scope
])
builds
=
filter_builds
(
builds
,
params
[
:scope
])
present
paginate
(
builds
),
with:
Entities
::
Build
present
paginate
(
builds
),
with:
Entities
::
Build
,
user_can_download_artifacts:
can?
(
current_user
,
:download_build_artifacts
,
user_project
)
end
end
# Get a specific build of a project
# Get a specific build of a project
...
@@ -47,7 +50,8 @@ module API
...
@@ -47,7 +50,8 @@ module API
build
=
get_build
(
params
[
:build_id
])
build
=
get_build
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
return
not_found!
(
build
)
unless
build
present
build
,
with:
Entities
::
Build
present
build
,
with:
Entities
::
Build
,
user_can_download_artifacts:
can?
(
current_user
,
:download_build_artifacts
,
user_project
)
end
end
# Get a trace of a specific build of a project
# Get a trace of a specific build of a project
...
@@ -84,7 +88,8 @@ module API
...
@@ -84,7 +88,8 @@ module API
build
.
cancel
build
.
cancel
present
build
,
with:
Entities
::
Build
present
build
,
with:
Entities
::
Build
,
user_can_download_artifacts:
can?
(
current_user
,
:download_build_artifacts
,
user_project
)
end
end
# Retry a specific build of a project
# Retry a specific build of a project
...
@@ -102,7 +107,8 @@ module API
...
@@ -102,7 +107,8 @@ module API
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
,
:download_build_artifacts
,
user_project
)
end
end
end
end
...
...
lib/api/entities.rb
View file @
1eb7b5ee
...
@@ -366,16 +366,8 @@ module API
...
@@ -366,16 +366,8 @@ module API
expose
:id
,
:variables
expose
:id
,
:variables
end
end
class
CiCommit
<
Grape
::
Entity
class
Runner
<
Grape
::
Entity
expose
:id
expose
:id
expose
:ref
expose
:sha
expose
:committed_at
end
class
CiRunner
<
Grape
::
Entity
expose
:id
expose
:token
expose
:description
expose
:description
expose
:active
expose
:active
expose
:is_shared
expose
:is_shared
...
@@ -383,16 +375,23 @@ module API
...
@@ -383,16 +375,23 @@ module API
end
end
class
Build
<
Grape
::
Entity
class
Build
<
Grape
::
Entity
expose
:id
expose
:id
,
:status
,
:stage
,
:name
,
:ref
,
:tag
,
:coverage
,
:user
expose
:status
expose
:created_at
,
:started_at
,
:finished_at
expose
:stage
expose
:download_url
do
|
repo_obj
,
options
|
expose
:name
if
options
[
:user_can_download_artifacts
]
expose
:ref
repo_obj
.
download_url
expose
:commit
,
with:
CiCommit
else
expose
:runner
,
with:
CiRunner
nil
expose
:created_at
end
expose
:started_at
end
expose
:finished_at
expose
:commit
,
with:
RepoCommit
do
|
repo_obj
,
_options
|
if
repo_obj
.
respond_to?
(
:commit
)
repo_obj
.
commit
.
commit_data
else
nil
end
end
expose
:runner
,
with:
Runner
end
end
end
end
end
end
spec/requests/api/builds_spec.rb
View file @
1eb7b5ee
...
@@ -74,7 +74,6 @@ describe API::API, api: true do
...
@@ -74,7 +74,6 @@ describe API::API, api: true do
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'name'
]).
to
eq
(
'test'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'test'
)
expect
(
json_response
[
'commit'
][
'sha'
]).
to
eq
(
commit
.
sha
)
end
end
it
'should return specific build trace'
do
it
'should return specific build trace'
do
...
...
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