diff options
Diffstat (limited to 'app/models/ci')
-rw-r--r-- | app/models/ci/build.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index d61f0bbfb10..f79a5682963 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -531,6 +531,7 @@ module Ci .concat(persisted_variables) .concat(scoped_variables) .concat(job_variables) + .concat(environment_changed_page_variables) .concat(persisted_environment_variables) .to_runner_variables end @@ -569,6 +570,15 @@ module Ci end end + def environment_changed_page_variables + Gitlab::Ci::Variables::Collection.new.tap do |variables| + break variables unless environment_status + + variables.append(key: 'CI_MERGE_REQUEST_CHANGED_PAGE_PATHS', value: environment_status.changed_paths.join(',')) + variables.append(key: 'CI_MERGE_REQUEST_CHANGED_PAGE_URLS', value: environment_status.changed_urls.join(',')) + end + end + def deploy_token_variables Gitlab::Ci::Variables::Collection.new.tap do |variables| break variables unless gitlab_deploy_token @@ -970,6 +980,14 @@ module Ci options&.dig(:environment, :url) || persisted_environment&.external_url end + def environment_status + strong_memoize(:environment_status) do + if has_environment? && merge_request + EnvironmentStatus.new(project, persisted_environment, merge_request, pipeline.sha) + end + end + end + # The format of the retry option changed in GitLab 11.5: Before it was # integer only, after it is a hash. New builds are created with the new # format, but builds created before GitLab 11.5 and saved in database still |