Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
4e06818d
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,发现更多精彩内容 >>
提交
4e06818d
编写于
11月 10, 2016
作者:
K
Kamil Trzcinski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support pipelines API
Pass `updated_at` to get only incremental changes since last update
上级
532c0319
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
32 addition
and
21 deletion
+32
-21
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+24
-5
app/models/commit_status.rb
app/models/commit_status.rb
+1
-10
app/views/projects/ci/pipelines/_pipeline.html.haml
app/views/projects/ci/pipelines/_pipeline.html.haml
+4
-3
app/views/projects/commit/_pipeline.html.haml
app/views/projects/commit/_pipeline.html.haml
+1
-1
app/views/projects/commit/_pipelines_list.haml
app/views/projects/commit/_pipelines_list.haml
+1
-1
app/views/projects/pipelines/index.html.haml
app/views/projects/pipelines/index.html.haml
+1
-1
未找到文件。
app/models/ci/pipeline.rb
浏览文件 @
4e06818d
...
...
@@ -98,19 +98,38 @@ module Ci
sha
[
0
...
8
]
end
def
self
.
stages
# We use pluck here due to problems with MySQL which doesn't allow LIMIT/OFFSET in queries
CommitStatus
.
where
(
pipeline:
pluck
(
:id
)).
stages
end
def
self
.
total_duration
where
.
not
(
duration:
nil
).
sum
(
:duration
)
end
def
stages
statuses
.
group
(
'stage'
).
select
(
:stage
)
.
order
(
'max(stage_idx)'
)
end
def
stages_with_statuses
status_sql
=
statuses
.
latest
.
where
(
'stage=sg.stage'
).
status_sql
stages_with_statuses
=
CommitStatus
.
from
(
self
.
stages
,
:sg
).
pluck
(
'sg.stage'
,
status_sql
)
stages_with_statuses
.
map
do
|
stage
|
OpenStruct
.
new
(
name:
stage
.
first
,
status:
stage
.
last
,
pipeline:
self
)
end
end
def
stages_with_latest_statuses
statuses
.
latest
.
includes
(
project: :namespace
).
order
(
:stage_idx
).
group_by
(
&
:stage
)
end
def
artifacts
builds
.
latest
.
with_artifacts_not_expired
end
def
project_id
project
.
id
end
...
...
app/models/commit_status.rb
浏览文件 @
4e06818d
...
...
@@ -119,16 +119,7 @@ class CommitStatus < ActiveRecord::Base
def
self
.
stages
# We group by stage name, but order stages by theirs' index
unscoped
.
from
(
all
,
:sg
).
group
(
'stage'
).
order
(
'max(stage_idx)'
,
'stage'
).
pluck
(
'sg.stage'
)
end
def
self
.
stages_status
# We execute subquery for each stage to calculate a stage status
statuses
=
unscoped
.
from
(
all
,
:sg
).
group
(
'stage'
).
pluck
(
'sg.stage'
,
all
.
where
(
'stage=sg.stage'
).
status_sql
)
statuses
.
inject
({})
do
|
h
,
k
|
h
[
k
.
first
]
=
k
.
last
h
end
unscoped
.
from
(
all
,
:sg
).
group
(
'stage'
).
order
(
'max(stage_idx)'
,
'stage'
).
select
(
'sg.stage'
)
end
def
failed_but_allowed?
...
...
app/views/projects/ci/pipelines/_pipeline.html.haml
浏览文件 @
4e06818d
...
...
@@ -45,9 +45,10 @@
-
stages_status
=
pipeline
.
statuses
.
latest
.
stages_status
%td
.stage-cell
-
stages
.
each
do
|
stage
|
-
status
=
stages_status
[
stage
]
-
tooltip
=
"
#{
stage
.
titleize
}
:
#{
status
||
'not found'
}
"
-
pipeline
.
statuses
.
latest
.
stages_status
.
each
do
|
stage
|
-
name
=
stage
.
first
-
status
=
stage
.
last
-
tooltip
=
"
#{
name
.
titleize
}
:
#{
status
||
'not found'
}
"
-
if
status
.stage-container
=
link_to
namespace_project_pipeline_path
(
pipeline
.
project
.
namespace
,
pipeline
.
project
,
pipeline
.
id
,
anchor:
stage
),
class:
"has-tooltip ci-status-icon-
#{
status
}
"
,
title:
tooltip
do
...
...
app/views/projects/commit/_pipeline.html.haml
浏览文件 @
4e06818d
...
...
@@ -62,5 +62,5 @@
-
if
pipeline
.
project
.
build_coverage_enabled?
%th
Coverage
%th
-
pipeline
.
sta
tuses
.
relevant
.
sta
ges
.
each
do
|
stage
|
-
pipeline
.
stages
.
each
do
|
stage
|
=
render
'projects/commit/ci_stage'
,
stage:
stage
,
statuses:
pipeline
.
statuses
.
relevant
.
where
(
stage:
stage
)
app/views/projects/commit/_pipelines_list.haml
浏览文件 @
4e06818d
...
...
@@ -12,4 +12,4 @@
%th
Stages
%th
%th
=
render
pipelines
,
commit_sha:
true
,
stage:
true
,
allow_retry:
true
,
s
tages:
pipelines
.
stages
,
s
how_commit:
false
=
render
pipelines
,
commit_sha:
true
,
stage:
true
,
allow_retry:
true
,
show_commit:
false
app/views/projects/pipelines/index.html.haml
浏览文件 @
4e06818d
...
...
@@ -51,6 +51,6 @@
%th
Stages
%th
%th
.hidden-xs
=
render
@pipelines
,
commit_sha:
true
,
stage:
true
,
allow_retry:
true
,
stages:
stages
=
render
@pipelines
,
commit_sha:
true
,
stage:
true
,
allow_retry:
true
=
paginate
@pipelines
,
theme:
'gitlab'
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录