To achieve that you need to use ${{ variables.vmImage }} because it is set at compilation time. More info https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch
jobs:
- job: RunTests
displayName: 'Run Tests on ${{ variables.vmImage }}'
timeoutInMinutes: 60
strategy:
matrix:
windows:
vmImage: 'windows-latest'
mac:
vmImage: 'macos-latest'
pool:
vmImage: $(vmImage)
steps: