Commit 91a9573d authored by Marius Bobin's avatar Marius Bobin Committed by Kerri Miller

Enable by default variable expansion in rules:changes

Enable by default variable expansion for variables in rules:changes
parent 9b7fe9c1
---
title: Add variable expansion to rules:changes
merge_request: 47783
author:
type: added
......@@ -4,4 +4,4 @@ introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45037
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/267192
type: development
group: group::pipeline authoring
default_enabled: false
default_enabled: true
......@@ -1350,10 +1350,11 @@ if there is no `if:` statement that limits the job to branch or merge request pi
##### Variables in `rules:changes`
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/34272) in GitLab 13.6.
> - It's [deployed behind a feature flag](../../user/feature_flags.md), disabled by default.
> - It's disabled on GitLab.com.
> - It's not recommended for production use.
> - To use it in GitLab self-managed instances, ask a GitLab administrator to [enable it](#enable-or-disable-variables-support-in-ruleschanges). **(CORE ONLY)**
> - It was [deployed behind a feature flag](../../user/feature_flags.md), disabled by default.
> - [Became enabled by default](https://gitlab.com/gitlab-org/gitlab/-/issues/267192) in GitLab 13.6.
> - It's enabled on GitLab.com.
> - It's recommended for production use.
> - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#enable-or-disable-variables-support-in-ruleschanges). **(CORE ONLY)**
CAUTION: **Warning:**
This feature might not be available to you. Check the **version history** note above for details.
......@@ -1377,10 +1378,10 @@ The `$` character can be used for both variables and paths. For example, if the
###### Enable or disable variables support in `rules:changes` **(CORE ONLY)**
Variables support in `rules:changes` is under development and not ready for production use. It is
deployed behind a feature flag that is **disabled by default**.
Variables support in `rules:changes` is under development, but is ready for production use.
It is deployed behind a feature flag that is **enabled by default**.
[GitLab administrators with access to the GitLab Rails console](../../administration/feature_flags.md)
can enable it.
can opt to disable it.
To enable it:
......
......@@ -20,7 +20,7 @@ module Gitlab
end
def expand_globs(pipeline, context)
return @globs unless ::Feature.enabled?(:ci_variable_expansion_in_rules_changes, pipeline.project)
return @globs unless ::Feature.enabled?(:ci_variable_expansion_in_rules_changes, pipeline.project, default_enabled: true)
return @globs unless context
@globs.map do |glob|
......
......@@ -19,13 +19,11 @@ RSpec.describe Gitlab::Ci::Build::Rules::Rule::Clause::Changes do
let(:modified_paths) { ['helm/test.txt'] }
let(:globs) { ['$HELM_DIR/**/*'] }
let(:context) { double('context') }
let(:variables) { [] }
subject { described_class.new(globs).satisfied_by?(pipeline, context) }
before do
allow(pipeline).to receive(:modified_paths).and_return(modified_paths)
allow(context).to receive(:variables).and_return(variables)
end
context 'when context is nil' do
......@@ -39,6 +37,10 @@ RSpec.describe Gitlab::Ci::Build::Rules::Rule::Clause::Changes do
[{ key: "HELM_DIR", value: "helm", public: true }]
end
before do
allow(context).to receive(:variables).and_return(variables)
end
it { is_expected.to be_truthy }
end
......@@ -46,6 +48,10 @@ RSpec.describe Gitlab::Ci::Build::Rules::Rule::Clause::Changes do
let(:globs) { ['path/with/$in/it/*'] }
let(:modified_paths) { ['path/with/$in/it/file.txt'] }
before do
allow(context).to receive(:variables).and_return([])
end
it { is_expected.to be_truthy }
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment