BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3145cbaa
Commit
3145cbaa
authored
Mar 21, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decouple pipeline stage seeds from building environments
parent
ad61a181
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
18 deletions
+21
-18
create_pipeline_stages_service.rb
app/services/ci/create_pipeline_stages_service.rb
+1
-11
create.rb
lib/gitlab/ci/pipeline/chain/create.rb
+13
-0
stage.rb
lib/gitlab/ci/pipeline/seed/stage.rb
+3
-5
yaml_processor.rb
lib/gitlab/ci/yaml_processor.rb
+4
-2
No files found.
app/services/ci/create_pipeline_stages_service.rb
View file @
3145cbaa
...
...
@@ -3,17 +3,7 @@ module Ci
def
execute
(
pipeline
)
pipeline
.
stage_seeds
.
each
do
|
seed
|
seed
.
user
=
current_user
seed
.
create!
do
|
build
|
##
# Create the environment before the build starts. This sets its slug and
# makes it available as an environment variable
#
if
build
.
has_environment?
environment_name
=
build
.
expanded_environment_name
project
.
environments
.
find_or_create_by
(
name:
environment_name
)
end
end
seed
.
create!
end
end
end
...
...
lib/gitlab/ci/pipeline/chain/create.rb
View file @
3145cbaa
...
...
@@ -14,6 +14,19 @@ module Gitlab
::
Ci
::
CreatePipelineStagesService
.
new
(
project
,
current_user
)
.
execute
(
pipeline
)
# TODO populate environments with find_or_initialize_by in the chain too.
##
# Create the environment before the build starts. This sets its slug and
# makes it available as an environment variable
#
pipeline
.
builds
.
each
do
|
build
|
if
build
.
has_environment?
environment_name
=
build
.
expanded_environment_name
project
.
environments
.
find_or_create_by
(
name:
environment_name
)
end
end
end
rescue
ActiveRecord
::
RecordInvalid
=>
e
error
(
"Failed to persist the pipeline:
#{
e
}
"
)
...
...
lib/gitlab/ci/pipeline/seed/stage.rb
View file @
3145cbaa
...
...
@@ -19,7 +19,9 @@ module Gitlab
end
def
attributes
{
name:
@name
,
pipeline:
@pipeline
,
project:
@pipeline
.
project
}
{
name:
@name
,
pipeline:
@pipeline
,
project:
@pipeline
.
project
}
end
# TODO decouple
...
...
@@ -43,10 +45,6 @@ module Gitlab
@pipeline
.
stages
<<
stage
stage
.
save!
stage
.
builds
.
each
do
|
build
|
yield
build
if
block_given?
end
end
end
end
...
...
lib/gitlab/ci/yaml_processor.rb
View file @
3145cbaa
...
...
@@ -73,8 +73,10 @@ module Gitlab
seeds
=
@stages
.
uniq
.
map
do
|
stage
|
builds
=
pipeline_stage_builds
(
stage
,
pipeline
)
Gitlab
::
Ci
::
Pipeline
::
Seed
::
Stage
.
new
(
pipeline
,
stage
,
builds
)
if
builds
.
any?
if
builds
.
any?
Gitlab
::
Ci
::
Pipeline
::
Seed
::
Stage
.
new
(
pipeline
,
stage
,
builds
)
end
end
seeds
.
compact
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment