summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-02-01 23:59:14 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-02-01 23:59:14 +0100
commite6487168ea1e0016a76e3e62f156990dd4412679 (patch)
treea8be6c33c094af653f91656225cb6beb62ad6487 /app
parenta31539847fd431e18053d0ea5a007dc38134b3f2 (diff)
downloadgitlab-ce-e6487168ea1e0016a76e3e62f156990dd4412679.tar.gz
Read the AutoDevOps instance domain in ProjectAutoDevOps
Diffstat (limited to 'app')
-rw-r--r--app/models/project.rb8
-rw-r--r--app/models/project_auto_devops.rb10
2 files changed, 9 insertions, 9 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index cbcf8b80e8e..ef67b86d3e8 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1609,13 +1609,7 @@ class Project < ActiveRecord::Base
def auto_devops_variables
return [] unless auto_devops_enabled?
- auto_devops&.variables || if current_application_settings.auto_devops_domain.present?
- [{ key: 'AUTO_DEVOPS_DOMAIN',
- value: current_application_settings.auto_devops_domain,
- public: true }]
- else
- []
- end
+ (auto_devops || ProjectAutoDevops.new)&.variables
end
def append_or_update_attribute(name, value)
diff --git a/app/models/project_auto_devops.rb b/app/models/project_auto_devops.rb
index 9a52edbff8e..f23310e854a 100644
--- a/app/models/project_auto_devops.rb
+++ b/app/models/project_auto_devops.rb
@@ -1,4 +1,6 @@
class ProjectAutoDevops < ActiveRecord::Base
+ include Gitlab::CurrentSettings
+
belongs_to :project
scope :enabled, -> { where(enabled: true) }
@@ -6,13 +8,17 @@ class ProjectAutoDevops < ActiveRecord::Base
validates :domain, allow_blank: true, hostname: { allow_numeric_hostname: true }
+ def instance_domain
+ current_application_settings.auto_devops_domain
+ end
+
def has_domain?
- domain.present?
+ domain.present? || instance_domain.present?
end
def variables
variables = []
- variables << { key: 'AUTO_DEVOPS_DOMAIN', value: domain, public: true } if domain.present?
+ variables << { key: 'AUTO_DEVOPS_DOMAIN', value: domain || instance_domain, public: true } if has_domain?
variables
end
end