Batch command syntax error when runing gitlab-runner

I am running gitlab runner on a local Windows computer. Config at the bottom.

When I run the unit test directly, as in: gitlab-runner exec shell test-unittest

Everything works, it compiles and tests.

However, when I run it automatically, as in: gitlab-runner run

I get the following error:

Time Elapsed 00:00:00.80
$ echo: testing…

$ dir /s /b RunnerUnitTest.dll | findstr /r bin\\ > tests_list.txt

$ for /f %f in (tests_list.txt) do vstest.console.exe "%f"

The syntax of the command is incorrect.
ERROR: Job failed: exit status 255

The first line is fine, just the second for loop at fault. But it runs from exec mode, it runs directly from the command line but not when running the whole stage. I have tried change %f to %%f too.

Here is the config


  • build
  • test

stage: build

  • ‘nuget restore’
  • ‘echo building…’
  • ‘msbuild.exe .\RunnerTest.sln’

stage: test

  • ‘echo: testing…’
  • ‘dir /s /b RunnerUnitTest.dll | findstr /r bin\ > tests_list.txt’
  • ‘for /f %f in (tests_list.txt) do vstest.console.exe “%f”’