Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
58486918
Commit
58486918
authored
Dec 08, 2016
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create environments when the build referencing them is created
parent
93a03cd9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
3 deletions
+31
-3
app/services/ci/create_pipeline_builds_service.rb
app/services/ci/create_pipeline_builds_service.rb
+13
-2
spec/models/environment_spec.rb
spec/models/environment_spec.rb
+1
-1
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+17
-0
No files found.
app/services/ci/create_pipeline_builds_service.rb
View file @
58486918
...
...
@@ -10,18 +10,29 @@ module Ci
end
end
def
project
pipeline
.
project
end
private
def
create_build
(
build_attributes
)
build_attributes
=
build_attributes
.
merge
(
pipeline:
pipeline
,
project:
p
ipeline
.
p
roject
,
project:
project
,
ref:
pipeline
.
ref
,
tag:
pipeline
.
tag
,
user:
current_user
,
trigger_request:
trigger_request
)
pipeline
.
builds
.
create
(
build_attributes
)
build
=
pipeline
.
builds
.
create
(
build_attributes
)
# Create the environment before the build starts. This sets its slug and
# makes it available as an environment variable
project
.
environments
.
find_or_create_by
(
name:
build
.
expanded_environment_name
)
if
build
.
has_environment?
build
end
def
new_builds
...
...
spec/models/environment_spec.rb
View file @
58486918
...
...
@@ -223,7 +223,7 @@ describe Environment, models: true do
"foo-"
=>
"foo"
+
SUFFIX
,
}.
each
do
|
name
,
matcher
|
it
"returns a slug matching
#{
matcher
}
, given
#{
name
}
"
do
slug
=
described_class
.
new
(
name:
name
).
generate_
clean_name
slug
=
described_class
.
new
(
name:
name
).
generate_
slug
expect
(
slug
).
to
match
(
/\A
#{
matcher
}
\z/
)
end
...
...
spec/services/ci/create_pipeline_service_spec.rb
View file @
58486918
...
...
@@ -210,5 +210,22 @@ describe Ci::CreatePipelineService, services: true do
expect
(
result
.
manual_actions
).
not_to
be_empty
end
end
context
'with environment'
do
before
do
config
=
YAML
.
dump
(
deploy:
{
environment:
{
name:
"review/$CI_BUILD_REF_NAME"
},
script:
'ls'
})
stub_ci_pipeline_yaml_file
(
config
)
end
it
'creates the environment'
do
result
=
execute
(
ref:
'refs/heads/master'
,
before:
'00000000'
,
after:
project
.
commit
.
id
,
commits:
[{
message:
'some msg'
}])
expect
(
result
).
to
be_persisted
expect
(
Environment
.
find_by
(
name:
"review/master"
)).
not_to
be_nil
end
end
end
end
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