diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-17 13:46:00 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-17 13:46:00 +0300 |
commit | 5f98d059396dc8c0faab4defd0414049c909b6c1 (patch) | |
tree | d6e3f2935d89d6bae212d3f4f307fe83e941f7f7 /app/services/create_deployment_service.rb | |
parent | 6cdbb27ec3cf72ce6728986909aa3df54b7a26c6 (diff) |
Add `action` and `on_stop` to `environment` in .gitlab-ci.yml
Diffstat (limited to 'app/services/create_deployment_service.rb')
-rw-r--r-- | app/services/create_deployment_service.rb | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/app/services/create_deployment_service.rb b/app/services/create_deployment_service.rb index 47c740addb0..2e859a30cac 100644 --- a/app/services/create_deployment_service.rb +++ b/app/services/create_deployment_service.rb @@ -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 |