Is there a way fail my entire pipeline if the user triggered the pipeline and didn't set a variable called options with a value?
I've tried things like only and rules but they just skip the job instead of failing all jobs.
Yes, though the way you fail would be dependent on the system your runner's based on.
For example, in a Linux/bash based runner, all you need is exit 1 (as opposed to exit 0) to stop execution and fail the pipeline
script: - if [$options == null]; then exit 1; fi The next line echos out options so I can see it's null but the if didn't exitif [ -z $options]; to make it a condition that checks if it's either unset, or null. This StackOverflow Question has a good summary of the different sorts of checks you could use here, but the approach above looks to be the best bet if you're looking to catch cases where the variable is unset or null.Testing the options environment variable in the script is one possibility. Another is to use the options variable to include (or exclude) a "killer" job from the pipeline. For example:
verify-options-set:
stage: .pre
image: node:20
tags:
- linux-docker
rules:
- if: '$options == null'
script:
- echo "Define "options" to run the pipeline!"
- exit 1
If the options environment variable is not set, this job (which always fails) is included in the pipeline. If it is set, the job is ignored.