Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
19789154
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,发现更多精彩内容 >>
提交
19789154
编写于
7月 26, 2017
作者:
S
Shinya Maeda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move validate to begin/rescue block
上级
1ad4efe6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
14 deletion
+19
-14
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+19
-14
未找到文件。
app/services/ci/create_pipeline_service.rb
浏览文件 @
19789154
module
Ci
class
CreatePipelineService
<
BaseService
class
ParameterValidationError
<
StandardError
end
attr_reader
:pipeline
def
execute
(
source
,
ignore_skip_ci:
false
,
save_on_errors:
true
,
trigger_request:
nil
,
schedule:
nil
)
...
...
@@ -15,13 +17,11 @@ module Ci
pipeline_schedule:
schedule
)
result
=
validate
(
current_user
||
trigger_request
.
trigger
.
owner
,
ignore_skip_ci:
ignore_skip_ci
,
save_on_errors:
save_on_errors
)
return
result
if
result
begin
validate
(
current_user
||
trigger_request
.
trigger
.
owner
,
ignore_skip_ci:
ignore_skip_ci
,
save_on_errors:
save_on_errors
)
Ci
::
Pipeline
.
transaction
do
pipeline
.
save!
...
...
@@ -31,8 +31,13 @@ module Ci
.
new
(
project
,
current_user
)
.
execute
(
pipeline
)
end
rescue
ParameterValidationError
=>
e
return
e
rescue
ActiveRecord
::
RecordInvalid
=>
e
return
error
(
"Failed to persist the pipeline:
#{
e
}
"
)
end
update_merge_requests_head_pipeline
...
...
@@ -48,30 +53,30 @@ module Ci
def
validate
(
triggering_user
,
ignore_skip_ci
:,
save_on_errors
:)
unless
project
.
builds_enabled?
r
eturn
error
(
'Pipeline is disabled'
)
r
aise
ParameterValidationError
,
error
(
'Pipeline is disabled'
)
end
unless
allowed_to_trigger_pipeline?
(
triggering_user
)
if
can?
(
triggering_user
,
:create_pipeline
,
project
)
r
eturn
error
(
"Insufficient permissions for protected ref '
#{
ref
}
'"
)
r
aise
ParameterValidationError
,
error
(
"Insufficient permissions for protected ref '
#{
ref
}
'"
)
else
r
eturn
error
(
'Insufficient permissions to create a new pipeline'
)
r
aise
ParameterValidationError
,
error
(
'Insufficient permissions to create a new pipeline'
)
end
end
unless
branch?
||
tag?
r
eturn
error
(
'Reference not found'
)
r
aise
ParameterValidationError
,
error
(
'Reference not found'
)
end
unless
commit
r
eturn
error
(
'Commit not found'
)
r
aise
ParameterValidationError
,
error
(
'Commit not found'
)
end
unless
pipeline
.
config_processor
unless
pipeline
.
ci_yaml_file
r
eturn
error
(
"Missing
#{
pipeline
.
ci_yaml_file_path
}
file"
)
r
aise
ParameterValidationError
,
error
(
"Missing
#{
pipeline
.
ci_yaml_file_path
}
file"
)
end
r
eturn
error
(
pipeline
.
yaml_errors
,
save:
save_on_errors
)
r
aise
ParameterValidationError
,
error
(
pipeline
.
yaml_errors
,
save:
save_on_errors
)
end
if
!
ignore_skip_ci
&&
skip_ci?
...
...
@@ -80,7 +85,7 @@ module Ci
end
unless
pipeline
.
has_stage_seeds?
r
eturn
error
(
'No stages / jobs for this pipeline.'
)
r
aise
ParameterValidationError
,
error
(
'No stages / jobs for this pipeline.'
)
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录