'can you use wildcards in the middle of directories in gitlab-ci.yml
According to: https://docs.gitlab.com/ee/ci/yaml/#onlychanges--exceptchanges, you can list wildcards for all subdirectories:
docker build:
script: docker build -t my-image:$CI_COMMIT_REF_SLUG .
only:
refs:
- branches
changes:
- Dockerfile
- docker/scripts/*
- dockerfiles/**/*
- more_scripts/*.{rb,py,sh}
- "**/*.json"
but what about if you want to include multiple directories? say I have a folder stucture like this:
server-a-files/**/*
server-b-files/**/*
server-c-files/**/*
etc. would something like this work?
docker build:
script: docker build -t my-image:$CI_COMMIT_REF_SLUG .
only:
refs:
- branches
changes:
- server-*-files/**/*
or would I need to do something like this:
docker build:
script: docker build -t my-image:$CI_COMMIT_REF_SLUG .
only:
refs:
- branches
changes:
- server-{a,b,c}-files/**/*
thanks!
Solution 1:[1]
Yes, you can use a wildcard in the middle of a path segment. GitLab uses Ruby's fnmatch for testing glob patterns for changes:.
irb(main):002:0> File.fnmatch('server-*-files/**/*', 'server-a-files/foo/bar')
=> true
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sytech |
