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:
authorKamil Trzciński <ayufan@ayufan.eu>2017-06-05 10:03:39 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2017-06-05 10:03:39 +0300
commitf71106425cc6f62c8e19457cc600e41a668fb89e (patch)
tree1e7e76837ca587ef883dd1da18d76817b5975676 /app/models
parent761e376404265cfef77f61601944a22690d55b5e (diff)
parent2fa766e10796ba07872ce0a5554d237bd7b153ee (diff)
Merge branch '25680-CI_ENVIRONMENT_URL' into 'master'
Add `$CI_ENVIRONMENT_URL` as a job variable Closes #25680 See merge request !11695
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/build.rb27
1 files changed, 24 insertions, 3 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 58dfdd87652..3bcc8be5cae 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -138,6 +138,17 @@ module Ci
ExpandVariables.expand(environment, simple_variables) if environment
end
+ def environment_url
+ return @environment_url if defined?(@environment_url)
+
+ @environment_url =
+ if unexpanded_url = options&.dig(:environment, :url)
+ ExpandVariables.expand(unexpanded_url, simple_variables)
+ else
+ persisted_environment&.external_url
+ end
+ end
+
def has_environment?
environment.present?
end
@@ -198,9 +209,7 @@ module Ci
# All variables, including those dependent on other variables
def variables
- variables = simple_variables
- variables += persisted_environment.predefined_variables if persisted_environment.present?
- variables
+ simple_variables.concat(persisted_environment_variables)
end
def merge_request
@@ -462,6 +471,18 @@ module Ci
variables.concat(legacy_variables)
end
+ def persisted_environment_variables
+ return [] unless persisted_environment
+
+ variables = persisted_environment.predefined_variables
+
+ if url = environment_url
+ variables << { key: 'CI_ENVIRONMENT_URL', value: url, public: true }
+ end
+
+ variables
+ end
+
def legacy_variables
variables = [
{ key: 'CI_BUILD_ID', value: id.to_s, public: true },