Skip to content
Snippets Groups Projects
Unverified Commit f77370ae authored by Laura Montemayor's avatar Laura Montemayor
Browse files

Merge branch 'cleanup-support_ci_environment_variables_in_job_rules-feature-flag' into 'master'

Clean up support_ci_environment_variables_in_job_rules feature flag

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/130804



Merged-by: default avatarLaura Montemayor <lmontemayor@gitlab.com>
Approved-by: default avatarHunter Stewart <hustewart@gitlab.com>
Approved-by: default avatarLaura Montemayor <lmontemayor@gitlab.com>
Co-authored-by: default avatarShinya Maeda <shinya@gitlab.com>
parents 5172aa57 f315c3eb
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -495,14 +495,7 @@ def persisted_environment_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless persisted? && persisted_environment.present?
 
if ::Feature.enabled?(:support_ci_environment_variables_in_job_rules, project)
variables.append(key: 'CI_ENVIRONMENT_SLUG', value: environment_slug)
else
variables.concat(persisted_environment.predefined_variables)
variables.append(key: 'CI_ENVIRONMENT_ACTION', value: environment_action)
variables.append(key: 'CI_ENVIRONMENT_TIER', value: environment_tier)
end
variables.append(key: 'CI_ENVIRONMENT_SLUG', value: environment_slug)
 
# Here we're passing unexpanded environment_url for runner to expand,
# and we need to make sure that CI_ENVIRONMENT_NAME and
Loading
Loading
---
name: support_ci_environment_variables_in_job_rules
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/128694
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/421377
milestone: '16.4'
type: development
group: group::environments
default_enabled: false
Loading
Loading
@@ -137,16 +137,11 @@ def predefined_variables(job, environment)
variables.append(key: 'CI_NODE_INDEX', value: job.options[:instance].to_s) if job.options&.include?(:instance)
variables.append(key: 'CI_NODE_TOTAL', value: ci_node_total_value(job).to_s)
 
if ::Feature.enabled?(:support_ci_environment_variables_in_job_rules, project)
if environment.present?
variables.append(key: 'CI_ENVIRONMENT_NAME', value: environment)
variables.append(key: 'CI_ENVIRONMENT_ACTION', value: job.environment_action)
variables.append(key: 'CI_ENVIRONMENT_TIER', value: job.environment_tier)
variables.append(key: 'CI_ENVIRONMENT_URL', value: job.environment_url) if job.environment_url
end
else
# Set environment name here so we can access it when evaluating the job's rules
variables.append(key: 'CI_ENVIRONMENT_NAME', value: job.environment) if job.environment # rubocop:disable Style/IfInsideElse
if environment.present?
variables.append(key: 'CI_ENVIRONMENT_NAME', value: environment)
variables.append(key: 'CI_ENVIRONMENT_ACTION', value: job.environment_action)
variables.append(key: 'CI_ENVIRONMENT_TIER', value: job.environment_tier)
variables.append(key: 'CI_ENVIRONMENT_URL', value: job.environment_url) if job.environment_url
end
end
end
Loading
Loading
Loading
Loading
@@ -171,20 +171,6 @@
 
it { expect(subject.to_runner_variables).to eq(predefined_variables) }
 
context 'when support_ci_environment_variables_in_job_rules feature flag is disabled' do
before do
stub_feature_flags(support_ci_environment_variables_in_job_rules: false)
# This is a bug. `CI_ENVIRONMENT_NAME` should be expanded.
predefined_variables.find { |var| var[:key] == 'CI_ENVIRONMENT_NAME' }[:value] = 'review/$CI_COMMIT_REF_NAME'
predefined_variables.delete_if do |var|
%w[CI_ENVIRONMENT_ACTION CI_ENVIRONMENT_TIER CI_ENVIRONMENT_URL].include?(var[:key])
end
end
it { expect(subject.to_runner_variables).to eq(predefined_variables) }
end
context 'variables ordering' do
def var(name, value)
{ key: name, value: value.to_s, public: true, masked: false }
Loading
Loading
Loading
Loading
@@ -2670,14 +2670,6 @@ def insert_expected_predefined_variables(variables, after:)
end
 
it_behaves_like 'containing environment variables'
context 'when support_ci_environment_variables_in_job_rules feature flag is disabled' do
before do
stub_feature_flags(support_ci_environment_variables_in_job_rules: false)
end
it_behaves_like 'containing environment variables'
end
end
 
context 'when an URL was set' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment