'Gitlab: Print custom warning

I wonder if it's possible to show a custom warning next to a Gitlab-CI job.

For example, I'd like in a single job to lint and style check a terraform configuration, print a warning if it doesn't pass, then create a terraform plan and stop the pipeline if that fails.

Is this feasible?



Solution 1:[1]

Turn on allow_failure (or set custom exit_codes) and exit with listed exit_codes. This will show a warning icon without blocking the pipeline.

test_job_2:
  script:
    - echo "Run a script that results in exit code 137. This job is allowed to fail."
    - exit 137
  allow_failure:
    exit_codes:
      - 137
      - 255

Ref: https://docs.gitlab.com/ee/ci/yaml/#allow_failure

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Festum