What is the difference between `before_script`, `script` and `after_script`?

BeginnerConceptGitLab CI
Answer

before_script and script are concatenated and run in the same shell, so a failure in either fails the job and variables persist between them. after_script runs in a separate shell, after the job even on failure (but not if the job is cancelled or times out hard), so it does not see variables or changes from script, though it sees the working directory files. Use it for cleanup and uploading diagnostics.

All CI/CD questions Roadmap: GitLab CI/CD

More on GitLab CI