From 05346c2fe6c110cd90e642f9ecb336d0fb6818e4 Mon Sep 17 00:00:00 2001 From: Naman Jagdish Gala <ngala@gitlab.com> Date: Tue, 11 Mar 2025 04:30:35 +0530 Subject: [PATCH] Move CI_PAGES_HOSTNAME from build.rb to project.rb Related: https://gitlab.com/gitlab-org/gitlab/-/issues/516166 Changelog: changed --- app/models/ci/build.rb | 4 +--- app/models/project.rb | 4 +++- spec/lib/gitlab/ci/variables/builder_spec.rb | 2 ++ spec/models/ci/build_spec.rb | 3 +-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 7e0a90482e25e..b73c5dc5e1201 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -636,9 +636,7 @@ def diffblue_cover_variables def pages_variables ::Gitlab::Ci::Variables::Collection.new.tap do |variables| - variables - .append(key: 'CI_PAGES_HOSTNAME', value: project.pages_hostname) - .append(key: 'CI_PAGES_URL', value: project.pages_url(pages)) + variables.append(key: 'CI_PAGES_URL', value: project.pages_url(pages)) end end diff --git a/app/models/project.rb b/app/models/project.rb index 01a8a8f48c6d4..3e9839657cbca 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2647,7 +2647,9 @@ def pages_variables Gitlab::Ci::Variables::Collection.new.tap do |variables| break unless pages_enabled? - variables.append(key: 'CI_PAGES_DOMAIN', value: Gitlab.config.pages.host) + variables + .append(key: 'CI_PAGES_DOMAIN', value: Gitlab.config.pages.host) + .append(key: 'CI_PAGES_HOSTNAME', value: pages_hostname) end end diff --git a/spec/lib/gitlab/ci/variables/builder_spec.rb b/spec/lib/gitlab/ci/variables/builder_spec.rb index d3a16fdf56d84..769c2576478be 100644 --- a/spec/lib/gitlab/ci/variables/builder_spec.rb +++ b/spec/lib/gitlab/ci/variables/builder_spec.rb @@ -95,6 +95,8 @@ value: project.ci_config_path_or_default }, { key: 'CI_PAGES_DOMAIN', value: Gitlab.config.pages.host }, + { key: 'CI_PAGES_HOSTNAME', + value: project.pages_hostname }, { key: 'CI_API_V4_URL', value: API::Helpers::Version.new('v4').root_url }, { key: 'CI_API_GRAPHQL_URL', diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 467e8f37d428b..5c9be449602d8 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -2582,6 +2582,7 @@ { key: 'CI_DEFAULT_BRANCH', value: project.default_branch, public: true, masked: false }, { key: 'CI_CONFIG_PATH', value: project.ci_config_path_or_default, public: true, masked: false }, { key: 'CI_PAGES_DOMAIN', value: Gitlab.config.pages.host, public: true, masked: false }, + { key: 'CI_PAGES_HOSTNAME', value: pages_hostname, public: true, masked: false }, { key: 'CI_DEPENDENCY_PROXY_SERVER', value: Gitlab.host_with_port, public: true, masked: false }, { key: 'CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX', value: "#{Gitlab.host_with_port}/#{project.namespace.root_ancestor.path.downcase}#{DependencyProxy::URL_SUFFIX}", @@ -2610,7 +2611,6 @@ { key: 'CI_COMMIT_REF_PROTECTED', value: (!!pipeline.protected_ref?).to_s, public: true, masked: false }, { key: 'CI_COMMIT_TIMESTAMP', value: pipeline.git_commit_timestamp, public: true, masked: false }, { key: 'CI_COMMIT_AUTHOR', value: pipeline.git_author_full_text, public: true, masked: false }, - { key: 'CI_PAGES_HOSTNAME', value: pages_hostname, public: true, masked: false }, { key: 'CI_PAGES_URL', value: pages_url, public: true, masked: false } ] end @@ -2682,7 +2682,6 @@ build_yaml_var, job_dependency_var, { key: 'secret', value: 'value', public: false, masked: false }, - { key: "CI_PAGES_HOSTNAME", value: pages_hostname, masked: false, public: true }, { key: "CI_PAGES_URL", value: pages_url, masked: false, public: true }]) end end -- GitLab