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
Léo-Paul Géneau
gitlab-ce
Commits
f4e7a889
Commit
f4e7a889
authored
Dec 24, 2015
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add builds API (listing, showing trace)
parent
835333c4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
0 deletions
+95
-0
lib/api/api.rb
lib/api/api.rb
+2
-0
lib/api/builds.rb
lib/api/builds.rb
+80
-0
lib/api/entities.rb
lib/api/entities.rb
+13
-0
No files found.
lib/api/api.rb
View file @
f4e7a889
...
...
@@ -54,5 +54,7 @@ module API
mount
Keys
mount
Tags
mount
Triggers
mount
Builds
end
end
lib/api/builds.rb
0 → 100644
View file @
f4e7a889
module
API
# Projects builds API
class
Builds
<
Grape
::
API
before
{
authenticate!
}
resource
:projects
do
# Get a project repository commits
#
# Parameters:
# id (required) - The ID of a project
# scope (optional) - The scope of builds to show (one of: all, finished, running)
# page (optional) - The page number for pagination (default: 1)
# per_page (ooptional) - The value of items per page to show (default 30)
# Example Request:
# GET /projects/:id/builds/all
get
':id/builds'
do
all_builds
=
user_project
.
builds
builds
=
all_builds
.
order
(
'created_at DESC'
)
builds
=
case
params
[
:scope
]
when
'all'
builds
when
'finished'
builds
.
finished
when
'running'
builds
.
running
when
'pending'
builds
.
pending
when
'success'
builds
.
success
when
'failed'
builds
.
failed
else
builds
.
running_or_pending
.
reverse_order
end
page
=
(
params
[
:page
]
||
1
).
to_i
per_page
=
(
params
[
:per_page
]
||
30
).
to_i
present
builds
.
page
(
page
).
per
(
per_page
),
with:
Entities
::
Build
end
# Get a specific build of a project
#
# Parameters:
# id (required) - The ID of a project
# build_id (required) - The ID of a build
# Example Request:
# GET /projects/:id/builds/:build_id
get
':id/builds/:build_id'
do
present
get_build
(
params
[
:build_id
]),
with:
Entities
::
Build
end
# Get a trace of a specific build of a project
#
# Parameters:
# id (required) - The ID of a project
# build_id (required) - The ID of a build
# Example Request:
# GET /projects/:id/build/:build_id/trace
get
':id/builds/:build_id/trace'
do
trace
=
get_build
(
params
[
:build_id
]).
trace
trace
=
unless
trace
.
nil?
trace
.
split
(
"
\n
"
)
else
[]
end
present
trace
end
end
helpers
do
def
get_build
(
id
)
user_project
.
builds
.
where
(
id:
id
).
first
end
end
end
end
lib/api/entities.rb
View file @
f4e7a889
...
...
@@ -366,5 +366,18 @@ module API
class
TriggerRequest
<
Grape
::
Entity
expose
:id
,
:variables
end
class
Build
<
Grape
::
Entity
expose
:id
expose
:status
expose
:stage
expose
:name
expose
:ref
expose
:commit
expose
:runner
expose
:created_at
expose
:started_at
expose
:finished_at
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