I'm running a gitlab job and in the job I'm trying to unset certain variables set in CI / CD Settings.
For example, I have
SOME_VARIABLE
set to <some_value>
Then, in the job definition, I'm trying
variables:
SOME_VARIABLE: ""
script:
- echo SOME_VARIABLE - [%SOME_VARIABLE%]
But in the job itself I'm still getting
SOME_VARIABLE - [<some_value>]
instead of
SOME_VARIABLE - []
Has anyone came across this?
I'll have to answer this since it might be rather obscure.
So turns out when you set a variable on Windows, you have to say
set v=some_value
To unset it, it needs to be
set v=
not
set v=''
When you set it to empty string it will be that, just quotes:
$ set v=""
$ echo %v%
""
If you unset it to empty correctly, you get:
$ set v=
$ echo %v%
%v%
However in gitlab, you can't leave values empty, such as
variables:
v:
because the it's invalid syntax.
So what I had to do was unset the variable in the script area:
script:
- set v=
- run_my_script_that_needs_v_unset
Then the script worked as needed.
(I imagine it can be done similarly on the other platforms.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With