Defining different `before_script` for each Gitlab runner executor type

I'm currently trying to run some Gitlab scripts on my local development environment using gitlab-runner. I'm trying to switch between the docker and shell executor type for a Gitlab script that's originally written for containerised execution. The before_script is currently defined with the assumption that it runs on fresh GNU/Linux environment every time so when I run the same script using shell executor on my macOS environment, I get errors. Is there a way to specify multiple versions of the before_script (or event the after_script) based on the executor? I know for standard job scripts, you can define tags so that jobs only run for certain types of runner. However, based on #15062 (closed), it doesn't seem to be currently possible for before_script's. Then again, even if tagging was supported in before_script, my local Gitlab runner after being registered with appropriate tags, can still switch between executor types.

What's the best way to approach this?

Assignee Loading
Time tracking Loading