Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
8f527cbf
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8f527cbf
编写于
10月 24, 2016
作者:
R
Robert Schilling
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Grapify builds API
上级
9af0dd5e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
79 addition
and
83 deletion
+79
-83
lib/api/builds.rb
lib/api/builds.rb
+79
-83
未找到文件。
lib/api/builds.rb
浏览文件 @
8f527cbf
...
...
@@ -3,15 +3,32 @@ module API
class
Builds
<
Grape
::
API
before
{
authenticate!
}
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
resource
:projects
do
# Get a project builds
#
# Parameters:
# id (required) - The ID of a project
# scope (optional) - The scope of builds to show (one or array of: created, pending, running, failed, success, canceled, skipped;
# if none provided showing all builds)
# Example Request:
# GET /projects/:id/builds
helpers
do
params
:optional_scope
do
optional
:scope
,
types:
[
String
,
Array
[
String
]],
desc:
'The scope of builds to show'
,
values:
[
'pending'
,
'running'
,
'failed'
,
'success'
,
'canceled'
],
coerce_with:
->
(
scope
)
{
if
scope
.
is_a?
(
String
)
[
scope
]
elsif
scope
.
is_a?
(
Hashie
::
Mash
)
scope
.
values
else
[
'unknown'
]
end
}
end
end
desc
'Get a project builds'
do
success
Entities
::
Build
end
params
do
use
:optional_scope
end
get
':id/builds'
do
builds
=
user_project
.
builds
.
order
(
'id DESC'
)
builds
=
filter_builds
(
builds
,
params
[
:scope
])
...
...
@@ -20,15 +37,13 @@ module API
user_can_download_artifacts:
can?
(
current_user
,
:read_build
,
user_project
)
end
# Get builds for a specific commit of a project
#
# Parameters:
# id (required) - The ID of a project
# sha (required) - The SHA id of a commit
# scope (optional) - The scope of builds to show (one or array of: created, pending, running, failed, success, canceled, skipped;
# if none provided showing all builds)
# Example Request:
# GET /projects/:id/repository/commits/:sha/builds
desc
'Get builds for a specific commit of a project'
do
success
Entities
::
Build
end
params
do
requires
:sha
,
type:
String
,
desc:
'The SHA id of a commit'
use
:optional_scope
end
get
':id/repository/commits/:sha/builds'
do
authorize_read_builds!
...
...
@@ -42,13 +57,12 @@ module API
user_can_download_artifacts:
can?
(
current_user
,
:read_build
,
user_project
)
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
desc
'Get a specific build of a project'
do
success
Entities
::
Build
end
params
do
requires
:build_id
,
type:
Integer
,
desc:
'The ID of a build'
end
get
':id/builds/:build_id'
do
authorize_read_builds!
...
...
@@ -58,13 +72,12 @@ module API
user_can_download_artifacts:
can?
(
current_user
,
:read_build
,
user_project
)
end
# Download the artifacts file from build
#
# Parameters:
# id (required) - The ID of a build
# token (required) - The build authorization token
# Example Request:
# GET /projects/:id/builds/:build_id/artifacts
desc
'Download the artifacts file from build'
do
detail
'This feature was introduced in GitLab 8.5'
end
params
do
requires
:build_id
,
type:
Integer
,
desc:
'The ID of a build'
end
get
':id/builds/:build_id/artifacts'
do
authorize_read_builds!
...
...
@@ -73,14 +86,13 @@ module API
present_artifacts!
(
build
.
artifacts_file
)
end
# Download the artifacts file from ref_name and job
#
# Parameters:
# id (required) - The ID of a project
# ref_name (required) - The ref from repository
# job (required) - The name for the build
# Example Request:
# GET /projects/:id/builds/artifacts/:ref_name/download?job=name
desc
'Download the artifacts file from build'
do
detail
'This feature was introduced in GitLab 8.10'
end
params
do
requires
:ref_name
,
type:
String
,
desc:
'The ref from repository'
requires
:job
,
type:
String
,
desc:
'The name for the build'
end
get
':id/builds/artifacts/:ref_name/download'
,
requirements:
{
ref_name:
/.+/
}
do
authorize_read_builds!
...
...
@@ -91,17 +103,13 @@ module API
present_artifacts!
(
latest_build
.
artifacts_file
)
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
#
# TODO: We should use `present_file!` and leave this implementation for backward compatibility (when build trace
# is saved in the DB instead of file). But before that, we need to consider how to replace the value of
# `runners_token` with some mask (like `xxxxxx`) when sending trace file directly by workhorse.
desc
'Get a trace of a specific build of a project'
params
do
requires
:build_id
,
type:
Integer
,
desc:
'The ID of a build'
end
get
':id/builds/:build_id/trace'
do
authorize_read_builds!
...
...
@@ -115,13 +123,12 @@ module API
body
trace
end
# Cancel a specific build of a project
#
# parameters:
# id (required) - the id of a project
# build_id (required) - the id of a build
# example request:
# post /projects/:id/build/:build_id/cancel
desc
'Cancel a specific build of a project'
do
success
Entities
::
Build
end
params
do
requires
:build_id
,
type:
Integer
,
desc:
'The ID of a build'
end
post
':id/builds/:build_id/cancel'
do
authorize_update_builds!
...
...
@@ -133,13 +140,12 @@ module API
user_can_download_artifacts:
can?
(
current_user
,
:read_build
,
user_project
)
end
# Retry a specific build of a project
#
# parameters:
# id (required) - the id of a project
# build_id (required) - the id of a build
# example request:
# post /projects/:id/build/:build_id/retry
desc
'Retry a specific build of a project'
do
success
Entities
::
Build
end
params
do
requires
:build_id
,
type:
Integer
,
desc:
'The ID of a build'
end
post
':id/builds/:build_id/retry'
do
authorize_update_builds!
...
...
@@ -152,13 +158,12 @@ module API
user_can_download_artifacts:
can?
(
current_user
,
:read_build
,
user_project
)
end
# Erase build (remove artifacts and build trace)
#
# Parameters:
# id (required) - the id of a project
# build_id (required) - the id of a build
# example Request:
# post /projects/:id/build/:build_id/erase
desc
'Erase build (remove artifacts and build trace)'
do
success
Entities
::
Build
end
params
do
requires
:build_id
,
type:
Integer
,
desc:
'The ID of a build'
end
post
':id/builds/:build_id/erase'
do
authorize_update_builds!
...
...
@@ -170,13 +175,12 @@ module API
user_can_download_artifacts:
can?
(
current_user
,
:download_build_artifacts
,
user_project
)
end
# Keep the artifacts to prevent them from being deleted
#
# Parameters:
# id (required) - the id of a project
# build_id (required) - The ID of a build
# Example Request:
# POST /projects/:id/builds/:build_id/artifacts/keep
desc
'Keep the artifacts to prevent them from being deleted'
do
success
Entities
::
Build
end
params
do
requires
:build_id
,
type:
Integer
,
desc:
'The ID of a build'
end
post
':id/builds/:build_id/artifacts/keep'
do
authorize_update_builds!
...
...
@@ -235,14 +239,6 @@ module API
return
builds
if
scope
.
nil?
||
scope
.
empty?
available_statuses
=
::
CommitStatus
::
AVAILABLE_STATUSES
scope
=
if
scope
.
is_a?
(
String
)
[
scope
]
elsif
scope
.
is_a?
(
Hashie
::
Mash
)
scope
.
values
else
[
'unknown'
]
end
unknown
=
scope
-
available_statuses
render_api_error!
(
'Scope contains invalid value(s)'
,
400
)
unless
unknown
.
empty?
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录