We are seeing a weird issue where any yarn
command in a script
block will terminate that script block after the yarn command.
steps:
- script: |
echo "*********1*********"
cd D:\my\src
echo "*********2*********"
yarn add --dev jest-junit
echo "*********3*********"
yarn test:unit --silent --ci --reporters=jest-junit
echo "*********4*********"
Will produce this output:
"*********1*********"
"*********2*********"
yarn add v1.16.0
[1/4] Resolving packages...
...
Done in 107.91s.
Finishing: CmdLine
So we never get to echo "*********3*********"
Even something like simple like this:
- script: |
echo "Start"
yarn -v
echo "We never get here"
It seems the Cmdline task just stops after the first yarn task.
This is running on an on-premise Windows Server 2016. If we run the same script on an ubuntu vm it works fine.
The problem is that yarn
is not an executable, it's a batch file.
According to the documentation, you should use call
when calling a batch file:
Azure Pipelines puts your inline script contents into a temporary batch file (.cmd) in order to run it. When you want to run a batch file from another batch file in Windows CMD, you must use the call command, otherwise the first batch file is terminated. This will result in Azure Pipelines running your intended script up until the first batch file, then running the batch file, then ending the step. Additional lines in the first script wouldn't be run. You should always prepend call before executing a batch file in an Azure Pipelines script step.
So in your case, yarn ...
should be changed to call yarn ...