Control job execution in before script

Hi,

The goal is to only run a pipeline if the version (parsed from file in repository) has gone up.

I’ve tried controlling job execution by evaluating a environment variable that has been set in the before_script.
Reference to documentation
gitlab-ci.yml testing

This doesn’t work. I guess the evaluation happens before the ci job is even started.
Is there a way to stop the execution if something in the before_script returns “False”?

Recomendation on how this could be achieved are welcome.

Thanks and cheers
C