Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-09-20 12:18:13 +0300
committerTimothy Andrew <mail@timothyandrew.net>2016-09-20 12:18:13 +0300
commitfa890604aaf15b9e4f0199e6a4cff24c29955a37 (patch)
tree1606c5585a93d3c0449effbe7b5cc901900833dd /app/services/create_deployment_service.rb
parent0b97b42d60a662c0d138c44f6dbd05a3048ac349 (diff)
parent95b9421ad3b2678da6e0af0131eafd52cdd0b2a5 (diff)
Merge remote-tracking branch 'origin/master' into 21170-cycle-analytics
Diffstat (limited to 'app/services/create_deployment_service.rb')
-rw-r--r--app/services/create_deployment_service.rb38
1 files changed, 35 insertions, 3 deletions
diff --git a/app/services/create_deployment_service.rb b/app/services/create_deployment_service.rb
index c126b2fad31..aad5cc8a15b 100644
--- a/app/services/create_deployment_service.rb
+++ b/app/services/create_deployment_service.rb
@@ -2,9 +2,7 @@ require_relative 'base_service'
class CreateDeploymentService < BaseService
def execute(deployable = nil)
- environment = project.environments.find_or_create_by(
- name: params[:environment]
- )
+ environment = find_or_create_environment
deployment = project.deployments.create(
environment: environment,
@@ -45,4 +43,38 @@ class CreateDeploymentService < BaseService
where.not(id: current_deployment.id).
first
end
+
+ 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
+
+ def expanded_url
+ return unless url
+
+ @expanded_url ||= ExpandVariables.expand(url, variables)
+ end
+
+ def name
+ params[:environment]
+ end
+
+ def url
+ options[:url]
+ end
+
+ def options
+ params[:options] || {}
+ end
+
+ def variables
+ params[:variables] || []
+ end
end