In Azure Pipelines I'm trying to modify the value of a matrix variable with an expression as shown below.
I saw the example in How to reference an Azure DevOps matrix variable, inside an expression? but it only shows how to access a variable, not how to modify the value in an expression.
stages:
- stage: Test
jobs:
- job: Test
strategy:
matrix:
'Python 3.9':
image: 'ubuntu-20.04'
python_version: '3.9'
pytag: 'py39'
'Python 3.10':
image: 'ubuntu-20.04'
python_version: '3.10'
pytag: 'py310'
pool:
vmImage: $(image)
variables:
var_a: $[replace(variables['python_version'], '.', '')]
steps:
- script: |
echo python_version '$(python_version)'
echo pytag $(pytag)
echo var_a $(var_a)
echo expression $[replace(variables['python_version'], '.', '')]
displayName: 'Output Test'
I'm trying to get rid of the pytag variables in the matrix and to compute them within the pipeline.
I would expect the output to contain env_a py39, but I receive the following output.
python_version 3.9
pytag py39
env_a
/home/vsts/work/_temp/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.sh: line 5: replace(variables['python_version'], '.', ''): syntax error in expression (error token is "(variables['python_version'], '.', '')")
##[error]Bash exited with code '1'.