Skip to content

Add bash exit code check to gitlab ci variables

Why is this change being made?

Pipeline #262542571 failed and we think it was related to gitlab-org/gitlab-runner#25394 (closed).

Based on gitlab-org/gitlab-runner!2671 (merged), which closed that issue, I think we have to enable it with a feature flag.

I ran this with a test job which failed appropriately, I think.

Manual QA

Refer to the instructions in the feature flag MR.

  1. Check out this branch locally
  2. Add the following job to .gitlab-ci.yml:
build_1:
  script:
    - false && true
    - echo $?
  1. If you have an updated version of GitLab Runner on your machine, you can commit your changes and run gitlab-runner exec shell build_1
  2. You should get some output that looks like this:
Runtime platform                                    arch=amd64 os=darwin pid=26447 revision=2ebc4dc4 version=13.9.0
Running with gitlab-runner 13.9.0 (2ebc4dc4)
  feature flags: FF_ENABLE_BASH_EXIT_CODE_CHECK:true
Preparing the "shell" executor
Using Shell executor...
executor not supported                              job=1 project=0 referee=metrics
Preparing environment
Running on Tylers-MacBook-Pro.local...
Getting source from Git repository
Fetching changes...
Reinitialized existing Git repository in /Users/tylerwilliams/Dev/www-gitlab-com/builds/0/project-0/.git/
Checking out 6161b532 as add-bash-exit-code-check-to-gitlab-ci-variables...
Skipping Git submodules setup
Executing "step_script" stage of the job script
$ false && true
ERROR: Job failed: exit status 1
FATAL: exit status 1    
  1. If you then change FF_ENABLE_BASH_EXIT_CODE_CHECK: "true" to FF_ENABLE_BASH_EXIT_CODE_CHECK: "false", commit your change, and run gitlab-runner exec shell build_1, you'll see something like this:
Runtime platform                                    arch=amd64 os=darwin pid=27699 revision=2ebc4dc4 version=13.9.0
Running with gitlab-runner 13.9.0 (2ebc4dc4)
Preparing the "shell" executor
Using Shell executor...
executor not supported                              job=1 project=0 referee=metrics
Preparing environment
Running on Tylers-MacBook-Pro.local...
Getting source from Git repository
Fetching changes...
Reinitialized existing Git repository in /Users/tylerwilliams/Dev/www-gitlab-com/builds/0/project-0/.git/
Checking out 1389796a as add-bash-exit-code-check-to-gitlab-ci-variables...
Skipping Git submodules setup
Executing "step_script" stage of the job script
$ false && true
$ echo $?
0
Job succeeded

If you don't have gitlab-runner installed, you can make those changes in the branch and trigger the pipeline in the GitLab instance, but it's faster to check it locally.

Author Checklist

  • Provided a concise title for the MR
  • Added a description to this MR explaining the reasons for the proposed change, per say-why-not-just-what
  • Assign this change to the correct DRI
Edited by Tyler Williams

Merge request reports