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
5f98d059
Commit
5f98d059
authored
Oct 17, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `action` and `on_stop` to `environment` in .gitlab-ci.yml
parent
6cdbb27e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
16 deletions
+20
-16
app/services/create_deployment_service.rb
app/services/create_deployment_service.rb
+9
-13
lib/gitlab/ci/config/node/environment.rb
lib/gitlab/ci/config/node/environment.rb
+11
-3
No files found.
app/services/create_deployment_service.rb
View file @
5f98d059
...
@@ -6,14 +6,12 @@ class CreateDeploymentService < BaseService
...
@@ -6,14 +6,12 @@ class CreateDeploymentService < BaseService
ActiveRecord
::
Base
.
transaction
do
ActiveRecord
::
Base
.
transaction
do
@deployable
=
deployable
@deployable
=
deployable
@environment
=
prepare_environment
@environment
=
environment
@environment
.
external_url
=
expanded_url
if
expanded_url
@environment
.
state_event
=
action
@environment
.
save
if
stop?
return
if
@environment
.
stopped?
@environment
.
stop
return
end
@environment
.
start
deploy
.
tap
do
|
deployment
|
deploy
.
tap
do
|
deployment
|
deployment
.
update_merge_request_metrics!
deployment
.
update_merge_request_metrics!
...
@@ -37,10 +35,8 @@ class CreateDeploymentService < BaseService
...
@@ -37,10 +35,8 @@ class CreateDeploymentService < BaseService
deployable:
@deployable
)
deployable:
@deployable
)
end
end
def
prepare_environment
def
environment
project
.
environments
.
find_or_create_by
(
name:
expanded_name
)
do
|
environment
|
@environment
||=
project
.
environments
.
find_or_create_by
(
name:
expanded_name
)
environment
.
external_url
=
expanded_url
end
end
end
def
expanded_name
def
expanded_name
...
@@ -69,7 +65,7 @@ class CreateDeploymentService < BaseService
...
@@ -69,7 +65,7 @@ class CreateDeploymentService < BaseService
params
[
:variables
]
||
[]
params
[
:variables
]
||
[]
end
end
def
stop?
def
action
params
[
:options
].
fetch
(
:
stop
,
false
)
params
[
:options
].
fetch
(
:
action
,
'start'
)
end
end
end
end
lib/gitlab/ci/config/node/environment.rb
View file @
5f98d059
...
@@ -8,7 +8,7 @@ module Gitlab
...
@@ -8,7 +8,7 @@ module Gitlab
class
Environment
<
Entry
class
Environment
<
Entry
include
Validatable
include
Validatable
ALLOWED_KEYS
=
%i[name url
close
]
ALLOWED_KEYS
=
%i[name url
action on_stop
]
validations
do
validations
do
validate
do
validate
do
...
@@ -36,7 +36,11 @@ module Gitlab
...
@@ -36,7 +36,11 @@ module Gitlab
addressable_url:
true
,
addressable_url:
true
,
allow_nil:
true
allow_nil:
true
validates
:close
,
boolean:
true
,
allow_nil:
true
validates
:action
,
inclusion:
{
in:
%w[start stop]
,
message:
'should be start or stop, '
},
allow_nil:
true
validates
:on_stop
,
string:
true
,
allow_nil:
true
end
end
end
end
...
@@ -56,9 +60,13 @@ module Gitlab
...
@@ -56,9 +60,13 @@ module Gitlab
value
[
:url
]
value
[
:url
]
end
end
def
action
value
[
:action
]
||
'start'
end
def
value
def
value
case
@config
case
@config
when
String
then
{
name:
@config
}
when
String
then
{
name:
@config
,
action:
'start'
}
when
Hash
then
@config
when
Hash
then
@config
else
{}
else
{}
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