Commit 97310b16 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

docs: add advance example - allow a test job to fail

Fixes #2
parent 1ca976ed
Loading
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -528,3 +528,42 @@ go-mod-outdated:

This way, the job won't never appear in the project pipeline.
This technique may be used to hard-disable any non-configurable _to be continuous_ job.

### Example 4: allow a test job to fail

All _to be continuous_ test & analysis jobs implement a [progressive strategy](#test--analysis-jobs-rules).
With this strategy, test & analysis jobs are **not allowed to fail on production and integration branches**.

!!! WARNING "Why can't I configure this behavior?"

    _to be continuous_ considers it's an anti-pattern to allow a test or analysis job to fail.
    In practice, such an in-between choice quickly becomes totally useless because no one will 
    pay attention when it fails.
    
    _to be continuous_ position:

    * either you care about the topic addressed by the job: activate it, accept to break the pipeline 
    when the job fails, and fixing it shall be a priority to restore the pipeline.
    * either you don't really care: simply disable (or don't enable) the job.

    There should not be an in-between position.

Nevertheless if you want to change the strategy to allow a test or analysis job to fail, it can be done by overriding the job rules as follows (example with `docker-trivy`):

```yaml
include:
  - project: 'to-be-continuous/docker'
    file: '/templates/gitlab-ci-docker.yml'
    ref: '5.4.0'

# allow docker-trivy to fail
docker-trivy:
  rules:
    # next rule to preserve the Adaptive Pipeline's "early stage" behavior
    # (dev branch, no MR: manual & allow failure)
    - if: '$CI_MERGE_REQUEST_ID == null && $CI_OPEN_MERGE_REQUESTS == null'
      when: manual
      allow_failure: true
    # any other case: auto & allow failure
    - allow_failure: true
```