Get Exit Code of GitLab CI Job

Hi,

I am using Kubernetes runner, I’m wondering is there any way to get the exit code of the current job? I want to use this exit code in my after_script.

Something like this:

after_script:
  - if [[ $CI_JOB_EXIT_CODE == 126 ]]; then echo "Will do something here!"; fi;

Thank you!

Or this can help too:

What I am trying to do is to know how the job ended, I am getting this error occasionally:

ERROR: Job failed (system failure): prepare environment: timed out waiting for pod to start. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information

So I want to find if there is a timeout in CI job in my after_script.