Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e79ebabb
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,发现更多精彩内容 >>
提交
e79ebabb
编写于
3月 21, 2018
作者:
G
Grzegorz Bizon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Populate pipeline with objects before creating it
上级
6f20134d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
47 addition
and
17 deletion
+47
-17
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+1
-0
app/services/ci/pipeline_trigger_service.rb
app/services/ci/pipeline_trigger_service.rb
+4
-8
lib/gitlab/ci/pipeline/chain/create.rb
lib/gitlab/ci/pipeline/chain/create.rb
+0
-7
lib/gitlab/ci/pipeline/chain/populate.rb
lib/gitlab/ci/pipeline/chain/populate.rb
+32
-0
lib/gitlab/ci/pipeline/seed/stage.rb
lib/gitlab/ci/pipeline/seed/stage.rb
+0
-2
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
+10
-0
未找到文件。
app/services/ci/create_pipeline_service.rb
浏览文件 @
e79ebabb
...
...
@@ -7,6 +7,7 @@ module Ci
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Validate
::
Repository
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Validate
::
Config
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Skip
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Populate
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Create
].
freeze
def
execute
(
source
,
ignore_skip_ci:
false
,
save_on_errors:
true
,
trigger_request:
nil
,
schedule:
nil
,
&
block
)
...
...
app/services/ci/pipeline_trigger_service.rb
浏览文件 @
e79ebabb
...
...
@@ -16,8 +16,8 @@ module Ci
pipeline
=
Ci
::
CreatePipelineService
.
new
(
project
,
trigger
.
owner
,
ref:
params
[
:ref
])
.
execute
(
:trigger
,
ignore_skip_ci:
true
)
do
|
pipeline
|
pipeline
.
trigger_requests
.
create!
(
trigger:
trigger
)
create_pipeline_variables!
(
pipeline
)
pipeline
.
trigger_requests
.
build
(
trigger:
trigger
)
pipeline
.
variables
.
build
(
variables
)
end
if
pipeline
.
persisted?
...
...
@@ -33,14 +33,10 @@ module Ci
end
end
def
create_pipeline_variables!
(
pipeline
)
return
unless
params
[
:variables
]
variables
=
params
[
:variables
].
map
do
|
key
,
value
|
def
variables
params
[
:variables
].
to_h
.
map
do
|
key
,
value
|
{
key:
key
,
value:
value
}
end
pipeline
.
variables
.
create!
(
variables
)
end
end
end
lib/gitlab/ci/pipeline/chain/create.rb
浏览文件 @
e79ebabb
...
...
@@ -9,13 +9,6 @@ module Gitlab
::
Ci
::
Pipeline
.
transaction
do
pipeline
.
save!
@command
.
seeds_block
&
.
call
(
pipeline
)
pipeline
.
stage_seeds
.
each
do
|
seed
|
seed
.
user
=
current_user
seed
.
to_resource
.
save!
end
# TODO populate environments with find_or_initialize_by in the chain too.
##
...
...
lib/gitlab/ci/pipeline/chain/populate.rb
0 → 100644
浏览文件 @
e79ebabb
module
Gitlab
module
Ci
module
Pipeline
module
Chain
class
Populate
<
Chain
::
Base
PopulateError
=
Class
.
new
(
StandardError
)
def
perform!
##
# Populate pipeline with seeds block.
#
# It comes from a block argument to CreatePipelineService#execute.
#
@command
.
seeds_block
&
.
call
(
pipeline
)
pipeline
.
stage_seeds
.
each
do
|
seed
|
seed
.
user
=
current_user
pipeline
.
stages
<<
seed
.
to_resource
end
raise
Populate
::
PopulateError
if
pipeline
.
persisted?
end
def
break?
pipeline
.
persisted?
end
end
end
end
end
end
lib/gitlab/ci/pipeline/seed/stage.rb
浏览文件 @
e79ebabb
...
...
@@ -37,8 +37,6 @@ module Gitlab
stage
.
builds
<<
build
end
end
@pipeline
.
stages
<<
stage
end
end
end
...
...
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
浏览文件 @
e79ebabb
...
...
@@ -79,5 +79,15 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
expect
(
pipeline
.
stages
)
.
to
all
(
satisfy
{
|
stage
|
stage
.
project
.
present?
})
end
it
'can not be persisted without explicit pipeline assignment'
do
stage
=
subject
.
to_resource
pipeline
.
save!
expect
(
stage
).
not_to
be_persisted
expect
(
pipeline
.
reload
.
stages
.
count
).
to
eq
0
expect
(
pipeline
.
reload
.
builds
.
count
).
to
eq
0
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录