meta data for this page
rules
Use rules:if clauses to specify when to add a job to a pipeline:
If an if statement is true, add the job to the pipeline.
If an if statement is true, but it’s combined with when: never, do not add the job to the pipeline.
If no if statements are true, do not add the job to the pipeline.
conditional variables
build: rules: - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH variables: CCACHE_DISABLE: 1 - if: $CI_COMMIT_TAG variables: CCACHE_DISABLE: 1
workflow: rules: - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH variables: CCACHE_DISABLE: 1 CACHE_CCACHE_POLICY: pull - if: $CI_COMMIT_TAG variables: CCACHE_DISABLE: 1 CACHE_CCACHE_POLICY: pull - when: always .ccache: &cache-ccache key: cache-ccache paths: - .ccache policy: ${CACHE_CCACHE_POLICY} .build-target: cache: - <<: *cache-ccache
negate glob?
How to negate rules:changes pattern?
Not possible. rules:changes takes glob patterns and they are inclusive only.
You have to specify all paths/patterns to match one by one.
BUT:
Glob patterns are interpreted with Ruby’s File.fnmatch with the flags File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_EXTGLOB.
Ruby's fnmatch is used to handle patterns. It doesn't support ! character.
To write rule to do not match changes in
src/**/*
directory but matches s, sr, src2:
rules: - changes: - "{[^s]*,s,s[^r]*,sr,sr[^c]*,src?*}/**/*" - "*"
Note: second pattern * is for match any file (but not directory!)
More, to exclude src/ and doc/:
rules: - changes: - "{[^s^d]*,s,d,s[^r]*,d[^o],sr,do,sr[^c]*,do[^c]*,src?*,doc?*}/**/*" - "*"
More about: