Fix file variable quoting issue with cmd shell
What does this MR do?
This MR fixes the cmd shell, which was broken with the merge of !4341 (merged) . In particular, it would mis-quote the path given as the redirect to the echo command creating the file for File Variables. The command looks like echo. 2> "\\tmp\\gitlab-runner\\builds\\hlab\\isengard.tmp\\VAL
. This path is interpreted by windows as "try to access the gitlab-runner
share on the tmp
SMB server", which is very much not what we want.
To fix this, I reworked the code to first set the environment variable containing the path, which was already being set correctly. This then allows us to use that environment variable as the target of the echo commands, which is much less "risky" in terms of escaping.
What's the best way to test this MR?
I personally reproduce the issue this way:
- Run gitlab-runner on a linux machine
- Use the
ssh
executor to connect to a windows machine - set shell to
cmd
- Set
builds_dir
to/tmp/gitlab-runner/builds
in the config
on 16.6, this will break down completely.
What are the relevant issue numbers?
None