diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-06-21 14:16:08 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-06-21 14:16:08 +0000 |
commit | 6431118d85d4c3cbe108d5fa6edc202bc619b092 (patch) | |
tree | 79a8b19ea436d25a8be06fd2651dbdef1161adb3 /app/models | |
parent | 411163226841589ed92c97fcab0503d8b77368eb (diff) | |
parent | 2a7f1eec12657310e2f8a24b0a1f0a659b9363d6 (diff) | |
download | gitlab-ce-6431118d85d4c3cbe108d5fa6edc202bc619b092.tar.gz |
Merge branch '34008-fix-CI_ENVIRONMENT_URL-2' into 'master'
Don't expand CI_ENVIRONMENT_URL so runner would do
Closes #34008
See merge request !12344
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build.rb | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 58758f7ca8a..a300536532b 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -138,17 +138,6 @@ 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 @@ -192,7 +181,7 @@ module Ci slugified.gsub(/[^a-z0-9]/, '-')[0..62] end - # Variables whose value does not depend on other variables + # Variables whose value does not depend on environment def simple_variables variables = predefined_variables variables += project.predefined_variables @@ -207,7 +196,8 @@ module Ci variables end - # All variables, including those dependent on other variables + # All variables, including those dependent on environment, which could + # contain unexpanded variables. def variables simple_variables.concat(persisted_environment_variables) end @@ -481,9 +471,10 @@ module Ci variables = persisted_environment.predefined_variables - if url = environment_url - variables << { key: 'CI_ENVIRONMENT_URL', value: url, public: true } - end + # Here we're passing unexpanded environment_url for runner to expand, + # and we need to make sure that CI_ENVIRONMENT_NAME and + # CI_ENVIRONMENT_SLUG so on are available for the URL be expanded. + variables << { key: 'CI_ENVIRONMENT_URL', value: environment_url, public: true } if environment_url variables end @@ -506,6 +497,10 @@ module Ci variables end + def environment_url + options&.dig(:environment, :url) || persisted_environment&.external_url + end + def build_attributes_from_config return {} unless pipeline.config_processor |