Senior
What is the 'when: always' construct in GitLab CI? What is it used for?
sobes.tech AI
Answer from AI
In GitLab CI, the when: always construct is used in a job definition to indicate that this task should always be executed, regardless of the result of previous tasks (success, failure, cancellation).
This is useful for steps that need to run in any case, such as cleaning up resources, sending notifications, or collecting artifacts.
Example:
job_cleanup:
script:
- echo "Cleaning up resources"
when: always
In this example, job_cleanup will run even if previous jobs failed or were canceled.