Extend 'only' and 'except' to add environment variables
This is the original intent of #34785 (closed) that was then addressed differently, but the initial idea is valuable and allows to do more powerful improvements to Auto DevOps template (and also others).
Extending syntax, we add capabilities to select if a job should be executed or not if specific environment variables are set, extending
except. This is good since it allows to avoid creating the job if conditions are not met, saving a lot of runner resources.
Extend only the complex scope of
except, using the new keyword
variables that is in logical AND as it is now for
Note: This syntax change has to be considered alpha, and subject to change.
This is the proposed syntax:
only: variables: - $VAR1 # variable present, defined and non-empty - $VAR2 == "yes" # variable content equals to "yes" - $VAR3 == $VAR4 # variable on the left equals to variable on the right - $VAR5 == "" # variable defined but empty
- items on different lines are in logical OR
- string values must be enclosed between
- it is not possible to do variable interpolation in strings
- it is not possible to escape chars in strings
- no support for conjunction yet (in the first iteration)
Links / references
Make sure these are completed before closing the issue, with a link to the relevant commit.
Proposal from #23538 (closed)