Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
f52de2f7
Commit
f52de2f7
authored
May 15, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make variables expression pattern case-sensitivity explicit
parent
73aee958
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
doc/ci/variables/README.md
doc/ci/variables/README.md
+8
-0
spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb
.../lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb
+13
-0
spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb
spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb
+1
-0
No files found.
doc/ci/variables/README.md
View file @
f52de2f7
...
...
@@ -537,6 +537,12 @@ Below you can find supported syntax reference:
It is possible perform pattern matching against a variable and regular
expression. Expression like this evaluates to truth if matches are found.
Pattern matching is case-sensitive by default. Prepend `(?i)` to a
match-group to make a pattern case-insensitive.
Under the hood we are using [RE2 library][re2-library], see
[syntax documentation][re2-syntax] for reference.
### Unsupported predefined variables
Because GitLab evaluates variables before creating jobs, we do not support a
...
...
@@ -577,3 +583,5 @@ These variables are also not supported in a context of a
[
builds-policies
]:
../yaml/README.md#only-and-except-complex
[
dynamic-environments
]:
../environments.md#dynamic-environments
[
gitlab-deploy-token
]:
../../user/project/deploy_tokens/index.md#gitlab-deploy-token
[
re2-library
]:
https://github.com/google/re2
[
re2-syntax
]:
https://github.com/google/re2/wiki/Syntax
spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb
View file @
f52de2f7
...
...
@@ -63,5 +63,18 @@ describe Gitlab::Ci::Pipeline::Expression::Lexeme::Matches do
expect
(
operator
.
evaluate
).
to
eq
true
end
it
'supports regexp flags'
do
allow
(
left
).
to
receive
(
:evaluate
).
and_return
<<~
TEXT
My AWESOME content
TEXT
allow
(
right
).
to
receive
(
:evaluate
)
.
and_return
(
Gitlab
::
UntrustedRegexp
.
new
(
'(?i)awesome'
))
operator
=
described_class
.
new
(
left
,
right
)
expect
(
operator
.
evaluate
).
to
eq
true
end
end
end
spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb
View file @
f52de2f7
...
...
@@ -100,6 +100,7 @@ describe Gitlab::Ci::Pipeline::Expression::Statement do
"$PRESENT_VARIABLE =~ /^var.*/"
|
false
"$EMPTY_VARIABLE =~ /var.*/"
|
false
"$UNDEFINED_VARIABLE =~ /var.*/"
|
false
"$PRESENT_VARIABLE =~ /(?i)VAR.*/"
|
true
end
with_them
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment