1

I have this gitlab-ci.yml:

build-docker:
    stage: build-docker
    rules:
        - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
          changes:
            - app/Dockerfile
            - app/requirements.txt
          when: always
        - when: manual
          allow_failure: true
    image:
        name: alpine
        entrypoint: [""]
    script:
        - echo 'Git Pulling, building and restarting'

deploy:
    stage: deploy
    rules:
        - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
          changes:
            - app/**/*
          when: always
        - when: manual
          allow_failure: true
    image:
        name: alpine
        entrypoint: [""]
    script:
        - echo 'Git Pulling and restarting'

My problem is that I doesn't need to run deploy if the changed files are only app/Dockerfile and/or app/requirements.txt (because the build job already ran and does the same as the deploy stage, and more), but I need it to run if changes happen on any other file inside app folder.

I already tried this in the deploy stage:

- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
          changes:
            - "app/!(Dockerfile)"
            - "app/!(requirements.txt)"
            - app/**/*
          when: always
        - when: manual
          allow_failure: true

But this doesn't work as expected.

danielnelz
  • 3,794
  • 4
  • 25
  • 35

0 Answers0