title: Gitlab CI: How to fail a pipeline while still running subsequent stages/jobs
body: <p>I am trying to run some jobs in a &quot;test&quot; stage followed by one job in a &quot;monitor&quot; stage.
  The trouble is if the unit tests fail in the test stage, the entire pipeline fails and it skips my job in the monitor stage altogether.</p>
  <p>I can set the unit tests to allow failure, which lets the monitor stage run, but the pipeline will pass if the unit tests fail, and I don't want that.</p>
  <p>How do I have the monitor stage run its job while still having the pipeline fail if the unit tests fail?</p>
  <p>Here is the relevant configuration:</p>
  <pre><code>include:
    - project: templates/kubernetes
      ref: master
      file: /.kube-api-version-checks.yaml
    - local: .choose-runner.yaml
      ref: master
  .run_specs_script: &amp;run_specs_script |
    ./kubernetes/integration/specs/run-specs.sh $CI_COMMIT_SHA $TEST_NAMESPACE $ECR_BASE_URL/test/$IMAGE_NAME $PROCESSES ${UNIT_TEST_INSTANCE_TYPE:-c5d.12xlarge}
  
  .base_unit_tests:
    image: XXX
    stage: test
    coverage: '/TOTAL\sCOVERAGE:\s\d+\.\d+%/'
    variables:
      GIT_DEPTH: 1
    script:
      - *run_specs_script
    after_script:
      - kubectl delete ns $TEST_NAMESPACE
    artifacts:
      when: always
      reports:
        junit: tmp/*.xml
      paths:
        - tmp/*.xml
        - artifact.tar.gz
  
  unit_tests:
    extends:
      - .base_unit_tests
      - .integration
  
  unit_tests_dependency_update:
    extends:
      - .base_unit_tests
      - .low-priority
  
  
  unit_tests_dependencies_next:
    image: XXX
    stage: test
    allow_failure: true
    except:
      - web
      - triggers
    tags:
      - integration-green-kube-runner
    only:
      refs:
        - merge_requests
      variables:
        - $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /^hint\/upgrade/
    variables:
      GIT_DEPTH: 1
      DEPENDENCIES_NEXT: 1
      IMAGE_NAME: next
    script:
      - *run_specs_script
    after_script:
      - kubectl delete ns $TEST_NAMESPACE
    artifacts:
      when: always
      reports:
        junit: tmp/*.xml
      paths:
        - tmp/*.xml
        - artifact.tar.gz
  
  unit_tests_datadog:
    extends:
      - .integration
    stage: monitor
    image: node
    variables:
      DD_API_KEY: XXX
    before_script:
      - npm install -g @datadog/datadog-ci
    script:
      - DD_ENV=ci DATADOG_API_KEY=&quot;$DD_API_KEY&quot; DATADOG_SITE=datadoghq.com datadog-ci junit upload --service &lt;service&gt; ./tmp
    dependencies:
      - unit_tests
    when: always
  </code></pre>