Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
0aefeeb8
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,体验更适合开发者的 AI 搜索 >>
提交
0aefeeb8
编写于
10月 12, 2015
作者:
K
Kamil Trzcinski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Commit Status documentation
上级
7ef156a2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
94 addition
and
12 deletion
+94
-12
app/models/ci/commit.rb
app/models/ci/commit.rb
+1
-1
app/models/commit_status.rb
app/models/commit_status.rb
+1
-1
doc/api/commits.md
doc/api/commits.md
+82
-0
lib/api/commit_statuses.rb
lib/api/commit_statuses.rb
+10
-10
未找到文件。
app/models/ci/commit.rb
浏览文件 @
0aefeeb8
...
...
@@ -136,7 +136,7 @@ module Ci
latest_statuses
=
statuses
.
latest
.
to_a
latest_statuses
.
reject!
{
|
status
|
status
.
try
(
&
:allow_failure?
)
}
latest_statuses
.
select!
{
|
status
|
status
.
ref
==
nil
||
status
.
ref
==
ref
}
if
ref
latest_statuses
.
select!
{
|
status
|
status
.
ref
.
nil?
||
status
.
ref
==
ref
}
if
ref
if
latest_statuses
.
none?
return
'skipped'
...
...
app/models/commit_status.rb
浏览文件 @
0aefeeb8
...
...
@@ -5,7 +5,7 @@ class CommitStatus < ActiveRecord::Base
belongs_to
:user
validates
:commit
,
presence:
true
validates
:status
,
inclusion:
{
in:
%w(pending running failed success canceled)
}
validates
:status
,
inclusion:
{
in:
%w(pending running failed success canceled)
}
validates_presence_of
:name
...
...
doc/api/commits.md
浏览文件 @
0aefeeb8
...
...
@@ -157,3 +157,85 @@ Parameters:
"line_type"
:
"new"
}
```
## Get the status of a commit
Get the statuses of a commit in a project.
```
GET /projects/:id/repository/commits/:sha/statuses
```
Parameters:
-
`id`
(required) - The ID of a project
-
`sha`
(required) - The commit SHA
-
`ref`
(optional) - Filter by ref name, it can be branch or tag
-
`stage`
(optional) - Filter by stage
-
`name`
(optional) - Filer by status name, eg. jenkins
-
`all`
(optional) - The flag to return all statuses, not only latest ones
```
json
[
{
"id"
:
13
,
"sha"
:
"b0b3a907f41409829b307a28b82fdbd552ee5a27"
,
"ref"
:
"test"
,
"status"
:
"success"
,
"name"
:
"ci/jenkins"
,
"target_url"
:
"http://jenkins/project/url"
,
"description"
:
"Jenkins success"
,
"created_at"
:
"2015-10-12T09:47:16.250Z"
,
"started_at"
:
"2015-10-12T09:47:16.250Z"",
"
finished_at
": "
2015-10-12
T
09
:
47
:
16.262
Z
",
"
author
": {
"
id
": 1,
"
username
": "
admin
",
"
email
": "
admin@local.host
",
"
name
": "
Administrator
",
"
blocked
": false,
"
created_at
": "
2012-04-29
T
08
:
46
:
00
Z
"
}
}
]
```
## Post the status to commit
Adds or updates a status of a commit.
Optionally you can post comments on a specific line of a commit. Therefor both
`path`
,
`line_new`
and
`line_old`
are required.
```
POST /projects/:id/statuses/:sha
```
-
`id`
(required) - The ID of a project
-
`sha`
(required) - The commit SHA
-
`state`
(required) - The state of the status. Can be: pending, running, success, failed, canceled
-
`ref`
(optional) - The ref (branch or tag) to which the status refers
-
`name`
or
`context`
(optional) - The label to differentiate this status from the status of other systems. Default: "default"
-
`target_url`
(optional) - The target URL to associate with this status
-
`description`
(optional) - The short description of the status
```
json
{
"id"
:
13
,
"sha"
:
"b0b3a907f41409829b307a28b82fdbd552ee5a27"
,
"ref"
:
"test"
,
"status"
:
"success"
,
"name"
:
"ci/jenkins"
,
"target_url"
:
"http://jenkins/project/url"
,
"description"
:
"Jenkins success"
,
"created_at"
:
"2015-10-12T09:47:16.250Z"
,
"started_at"
:
"2015-10-12T09:47:16.250Z"",
"
finished_at
": "
2015-10-12
T
09
:
47
:
16.262
Z
",
"
author
": {
"
id
": 1,
"
username
": "
admin
",
"
email
": "
admin@local.host
",
"
name
": "
Administrator
",
"
blocked
": false,
"
created_at
": "
2012-04-29
T
08
:
46
:
00
Z
"
}
}
```
lib/api/commit_statuses.rb
浏览文件 @
0aefeeb8
...
...
@@ -56,16 +56,16 @@ module API
status
.
update
(
attrs
)
case
params
[
:state
].
to_s
when
'running'
status
.
run
when
'success'
status
.
success
when
'failed'
status
.
drop
when
'canceled'
status
.
cancel
else
status
.
status
=
params
[
:state
].
to_s
when
'running'
status
.
run
when
'success'
status
.
success
when
'failed'
status
.
drop
when
'canceled'
status
.
cancel
else
status
.
status
=
params
[
:state
].
to_s
end
if
status
.
save
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录