diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-15 00:00:15 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-19 11:07:13 +0300 |
commit | 6b979687459ad1ab5f1953bf451ee80fdb899b96 (patch) | |
tree | ff19ce3e4386a562a68cf9a9d9071ea7d02934ec /app/services/create_deployment_service.rb | |
parent | e1b3ab5af290f6d2eeb56c4b72e341324414a6d2 (diff) |
Update support for dynamic environments
Diffstat (limited to 'app/services/create_deployment_service.rb')
-rw-r--r-- | app/services/create_deployment_service.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/services/create_deployment_service.rb b/app/services/create_deployment_service.rb index 577ba731583..e6667132e27 100644 --- a/app/services/create_deployment_service.rb +++ b/app/services/create_deployment_service.rb @@ -2,13 +2,7 @@ require_relative 'base_service' class CreateDeploymentService < BaseService def execute(deployable = nil) - environment = project.environments.find_or_create_by( - name: expanded_name - ) - - if expanded_url - environment.external_url = expanded_url - end + environment = find_or_create_environment project.deployments.create( environment: environment, @@ -22,6 +16,12 @@ class CreateDeploymentService < BaseService private + def find_or_create_environment + project.environments.find_or_create_by(name: expanded_name) do |environment| + environment.external_url = expanded_url + end + end + def expanded_name ExpandVariables.expand(name, variables) end @@ -41,7 +41,7 @@ class CreateDeploymentService < BaseService end def options - params[:environment] || {} + params[:options] || {} end def variables |