meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
git:gitlab:ci:yaml:rules [2024/01/18 16:21] niziakgit:gitlab:ci:yaml:rules [2025/01/03 14:06] (current) niziak
Line 13: Line 13:
 [[https://docs.gitlab.com/ee/ci/yaml/#ruleschanges|rules:changes]] [[https://docs.gitlab.com/ee/ci/yaml/#ruleschanges|rules:changes]]
  
 +===== conditional variables =====
 +
 +<code yaml>
 +build:
 +  rules:
 +    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
 +      variables:
 +        CCACHE_DISABLE: 1
 +    - if: $CI_COMMIT_TAG
 +      variables:
 +        CCACHE_DISABLE: 1
 +</code>
 +
 +  * [[https://docs.gitlab.com/ee/ci/caching/index.html#use-a-variable-to-control-a-jobs-cache-policy|Use a variable to control a job’s cache policy]]
 +  * [[https://gitlab.com/gitlab-org/gitlab/-/issues/270415#note_1050526105|Support `cache` policies for job `rules`]]
 +
 +
 +<code yaml>
 +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
 +
 +</code>
  
 ===== negate glob? ===== ===== negate glob? =====
Line 27: Line 69:
 Ruby's fnmatch is used to handle patterns. It doesn't support ''!'' character. 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'':+To write rule to do not match changes in <code>src/**/*</code> directory but matches ''s'', ''sr'', ''src2'':
 <code yaml> <code yaml>
 rules: rules:
Line 34: Line 76:
     - "*"     - "*"
 </code> </code>
 +
 Note: second pattern ''*'' is for match any file (but not directory!) Note: second pattern ''*'' is for match any file (but not directory!)
 More, to exclude ''src/'' and ''doc/'': More, to exclude ''src/'' and ''doc/'':
 +
 <code yaml> <code yaml>
   rules:   rules: