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
1
Merge Requests
1
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
nexedi
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
Hide 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
ActiveRecord
::
Base
.
transaction
do
@deployable
=
deployable
@environment
=
prepare_environment
@environment
=
environment
@environment
.
external_url
=
expanded_url
if
expanded_url
@environment
.
state_event
=
action
@environment
.
save
if
stop?
@environment
.
stop
return
end
@environment
.
start
return
if
@environment
.
stopped?
deploy
.
tap
do
|
deployment
|
deployment
.
update_merge_request_metrics!
...
...
@@ -37,10 +35,8 @@ class CreateDeploymentService < BaseService
deployable:
@deployable
)
end
def
prepare_environment
project
.
environments
.
find_or_create_by
(
name:
expanded_name
)
do
|
environment
|
environment
.
external_url
=
expanded_url
end
def
environment
@environment
||=
project
.
environments
.
find_or_create_by
(
name:
expanded_name
)
end
def
expanded_name
...
...
@@ -69,7 +65,7 @@ class CreateDeploymentService < BaseService
params
[
:variables
]
||
[]
end
def
stop?
params
[
:options
].
fetch
(
:
stop
,
false
)
def
action
params
[
:options
].
fetch
(
:
action
,
'start'
)
end
end
lib/gitlab/ci/config/node/environment.rb
View file @
5f98d059
...
...
@@ -8,7 +8,7 @@ module Gitlab
class
Environment
<
Entry
include
Validatable
ALLOWED_KEYS
=
%i[name url
close
]
ALLOWED_KEYS
=
%i[name url
action on_stop
]
validations
do
validate
do
...
...
@@ -36,7 +36,11 @@ module Gitlab
addressable_url:
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
...
...
@@ -56,9 +60,13 @@ module Gitlab
value
[
:url
]
end
def
action
value
[
:action
]
||
'start'
end
def
value
case
@config
when
String
then
{
name:
@config
}
when
String
then
{
name:
@config
,
action:
'start'
}
when
Hash
then
@config
else
{}
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