Skip to content

Add AFTER_SCRIPT_IGNORE_ERRORS variable allow not ignoring after_script errors

Tim requested to merge timmmm/gitlab-runner:user/timh/after_script_fail into main
  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA

What does this MR do?

Add AFTER_SCRIPT_IGNORE_ERRORS variable allow not ignoring after_script errors

By default errors in after_script are ignored. This is not the desired behaviour for many uses of after_script, for example if you use it to check git is clean after each step then you don't want to ignore errors.

Arguably the behaviour should always have been to observe errors, since ignoring errors within the script is always possible (e.g. ./my_after_script.sh || true) but observing them if they are ignored by the runner is impossible.

This commit adds a variable AFTER_SCRIPT_IGNORE_ERRORS that can be set to false to not ignore errors in all after_scripts. The default is true and it also uses true if there's a parse error.

Why was this MR needed?

It's impossible to get this behaviour from the existing after_script. You can just add some extra stuff to the end of script, but that doesn't scale if you have lots of jobs, whereas with after_script you can have them all inherit a default one.

What's the best way to test this MR?

No idea; I'm afraid I haven't tested it at all!

What are the relevant issue numbers?

gitlab#21008

Edited by 🤖 GitLab Bot 🤖

Merge request reports