I have a problem in my gitlab-ci.yml
on Windows. I launch phpunit
with environments variables.
So, I have a variable like:
PHPUNIT : %SOURCE_PATH%\cgi-bin\php.exe %PHPUNIT_PATH%
And some variables are declared before:
SOURCE_PATH: 'C:\Source'
PHPUNIT_PATH: '"%SOURCE_PATH%\cgi-bin\tests\__init\tools\phpunit.phar"'
But when I use the CALL command, Windows doesn't resolve the variable inside the other variable.
So if I do:
CALL Echo %PHPUNIT%
I have:
C:\Source\cgi-bin\php.exe "%SOURCE_PATH%\cgi-bin\tests\__init\tools\phpunit.phar"
I think this is because of %SOURCE_PATH%
doesn't exist in CALL context.
But I could not find out how to pass the environment variables in the CALL. And I could not find another way to do this, too. (If I don't use CALL, the gitlab-ci stops when the inside script exits.)
I wish you can help me ...
Somethings to know.
My script is launched by gitlab-ci runner, so it is started by:
setlocal enableextensions
setlocal enableDelayedExpansion
set nl=^
And I can't change this.
I can use PowerShell if needed, or if you know another work around. :)
This batch file demonstrates on execution the problem and offers a solution.
Don't run SETLOCAL more than once for defining the command line environment with specifying the parameters
EnableExtensions
andEnableDelayedExpansion
. Both can be specified on running SETLOCAL only once. See this answer for a detailed explanation what the commands SETLOCAL and ENDLOCAL do which should make it clear why it is not advisable to run SETLOCAL more often than really needed.And enable delayed expansion only when really needed as exclamation marks in text to process or directory/file names or parameter strings are handled not anymore as literal character with delayed expansion enabled.
Your Question is Not so much clear... But, I may guess that - Your inbetween Scripts are using 'Exit' at the end. SO, Replace it with Exit /B
Or Try to Use 'Start' Instead of Call... (Start /B ... - Check 'Start /?')