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
Boxiang Sun
gitlab-ce
Commits
9bea3c0f
Commit
9bea3c0f
authored
Nov 15, 2018
by
Kirill Zaitsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add glob for CI changes detection
parent
97e3d5ce
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
1 deletion
+20
-1
changelogs/unreleased/added-glob-for-ci-changes-detection.yml
...gelogs/unreleased/added-glob-for-ci-changes-detection.yml
+5
-0
doc/ci/yaml/README.md
doc/ci/yaml/README.md
+2
-0
lib/gitlab/ci/build/policy/changes.rb
lib/gitlab/ci/build/policy/changes.rb
+1
-1
spec/lib/gitlab/ci/build/policy/changes_spec.rb
spec/lib/gitlab/ci/build/policy/changes_spec.rb
+12
-0
No files found.
changelogs/unreleased/added-glob-for-ci-changes-detection.yml
0 → 100644
View file @
9bea3c0f
---
title
:
Added glob for CI changes detection
merge_request
:
23128
author
:
Kirill Zaitsev
type
:
added
doc/ci/yaml/README.md
View file @
9bea3c0f
...
...
@@ -476,6 +476,7 @@ docker build:
-
Dockerfile
-
docker/scripts/*
-
dockerfiles/**/*
-
more_scripts/*.{rb,py,sh}
```
In the scenario above, if you are pushing multiple commits to GitLab to an
...
...
@@ -485,6 +486,7 @@ one of the commits contains changes to either:
-
The
`Dockerfile`
file.
-
Any of the files inside
`docker/scripts/`
directory.
-
Any of the files and subfolders inside
`dockerfiles`
directory.
-
Any of the files with
`rb`
,
`py`
,
`sh`
extensions inside
`more_scripts`
directory.
CAUTION:
**Warning:**
There are some caveats when using this feature with new branches and tags. See
...
...
lib/gitlab/ci/build/policy/changes.rb
View file @
9bea3c0f
...
...
@@ -14,7 +14,7 @@ module Gitlab
pipeline
.
modified_paths
.
any?
do
|
path
|
@globs
.
any?
do
|
glob
|
File
.
fnmatch?
(
glob
,
path
,
File
::
FNM_PATHNAME
|
File
::
FNM_DOTMATCH
)
File
.
fnmatch?
(
glob
,
path
,
File
::
FNM_PATHNAME
|
File
::
FNM_DOTMATCH
|
File
::
FNM_EXTGLOB
)
end
end
end
...
...
spec/lib/gitlab/ci/build/policy/changes_spec.rb
View file @
9bea3c0f
...
...
@@ -49,6 +49,12 @@ describe Gitlab::Ci::Build::Policy::Changes do
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
seed
)
end
it
'is satisfied by matching a pattern with a glob'
do
policy
=
described_class
.
new
(
%w[some/**/*.{rb,txt}]
)
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
seed
)
end
it
'is not satisfied when pattern does not match path'
do
policy
=
described_class
.
new
(
%w[some/*.rb]
)
...
...
@@ -61,6 +67,12 @@ describe Gitlab::Ci::Build::Policy::Changes do
expect
(
policy
).
not_to
be_satisfied_by
(
pipeline
,
seed
)
end
it
'is not satified when pattern with glob does not match'
do
policy
=
described_class
.
new
(
%w[invalid/*.{md,rake}]
)
expect
(
policy
).
not_to
be_satisfied_by
(
pipeline
,
seed
)
end
context
'when pipelines does not run for a branch update'
do
before
do
pipeline
.
before_sha
=
Gitlab
::
Git
::
BLANK_SHA
...
...
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