Skip to content

`allow_failure` for specific exit codes

Description

The current CI/CD jobs can either pass, fail, or pass-with-warnings, although there is no way for the running script to notify the state on exit.

The current use case for this is in the bizops/BizOps project, where we have ELT jobs that extract data from various sources. These jobs are expected to pass, but are flaky by design. I would like a way for the running job to control the job's status according to the exit codes of the script.

Examples:

  • I might hit an error that should abort the pipeline, so that should make the job fail so the rest of the pipeline stops.
  • There might be problems that cause the job to output warnings
  • The job might succeed

The only problem I have right now is that either we set allow_failure then we lose the fail state for this job or we can't have warnings.

Proposal

Add an exit code to the allow_failure (or a list)

pings:
  stage: extract
  retry: 1
  <<: *job_definition
  script:
    - set_sql_instance_name
    - setup_cloudsqlproxy
    - bash processes/hosts_to_sfdc/python_timecheck.sh
    - stop_cloudsqlproxy
  allow_failure: [2,3,4]

Links / references

/cc @joshlambert

Edited by Jason Yavorsky