How to create Gitlab CI rules that are evaluated as AND instead of OR

前端 未结 1 1974
轻奢々
轻奢々 2021-01-27 03:03

The following gitlab ci job will run if the variable $CI_COMMIT_TAG is set OR if the ./versions.txt file has changed.

some-job:
  script:
    -          


        
相关标签:
1条回答
  • 2021-01-27 03:26

    From Docs:

    In the following example:

    We run the job manually if Dockerfile or any file in docker/scripts/ has changed AND $VAR == "string value". Otherwise, the job will not be included in the pipeline.

    docker build:
          script: docker build -t my-image:$CI_COMMIT_REF_SLUG .
          rules:
            - if: '$VAR == "string value"'
              changes: # Will include the job and set to when:manual if any of the follow paths match a modified file.
              - Dockerfile
              - docker/scripts/*
              when: manual  
    

    Your code will look something like this.

    some-job:
      script:
        - echo "Do some fancy stuff.";
      rules:
        - if: $CI_COMMIT_TAG
          changes: 
            - versions.txt
          when: manual
    
    0 讨论(0)
提交回复
热议问题