[BUG]: split express function doesnt work variables get from parameters.
dbwodlf3 opened this issue · comments
What happened?
parameters:
- name: NODE_ENV
type: string
- name: IMG_NAME
type: string
- name: IMG_TAG
type: string
- name: AZURE_APP_SLOT
type: string
# Likes ase,brs,cnc
- name: AZURE_APP_REGIONS
type: string
jobs:
- job: deploy_service_to_slot
pool:
name: 'Azure Pipelines'
strategy:
matrix:
${{ each region in split('test1,test2,test3', ',')}}:
${{region}}:
REGION: ${{region}}
steps:
- checkout: none
- task: Bash@3
displayName: "print deploy variables"
continueOnError: false
inputs:
targetType: 'inline'
script: |
# Print Variables
echo "AZURE_SUBSCRIPTION::= $(AZURE_SUBSCRIPTION)"
echo "AZURE_APPNAME::= $(AZURE_APPNAME)"
echo "AZURE_APP_REGIONS::= $(AZURE_APP_REGIONS)"
echo "AZURE_APP_SLOT::= $(AZURE_APP_SLOT)"
echo "IMG_NAME::= $(IMG_NAME)"
echo "IMG_TAG::= $(IMG_TAG)"
echo: "REGION::= $(region)"
- task: AzureWebAppContainer@1
displayName: "Deploy to $(REGION)"
continueOnError: false
inputs:
azureSubscription: $(AZURE_SUBSCRIPTION)
appName: $(AZURE_APPNAME)-$(REGION)
imageName: $(IMG_NAME):$(IMG_TAG)
deployToSlotOrASE: true
slotName: $(AZURE_APP_SLOT)
appSettings:
-WEBSITES_PORT 8003
-NODE_ENV $(NODE_ENV)
it works. (test1, test2, test3 is splitted)
parameters:
- name: NODE_ENV
type: string
- name: IMG_NAME
type: string
- name: IMG_TAG
type: string
- name: AZURE_APP_SLOT
type: string
# Likes ase,brs,cnc
- name: AZURE_APP_REGIONS
type: string
jobs:
- job: deploy_service_to_slot
pool:
name: 'Azure Pipelines'
strategy:
matrix:
${{ each region in split(parameters.AZURE_APP_REGIONS, ',')}}:
${{region}}:
REGION: ${{region}}
steps:
- checkout: none
- task: Bash@3
displayName: "print deploy variables"
continueOnError: false
inputs:
targetType: 'inline'
script: |
# Print Variables
echo "AZURE_SUBSCRIPTION::= $(AZURE_SUBSCRIPTION)"
echo "AZURE_APPNAME::= $(AZURE_APPNAME)"
echo "AZURE_APP_REGIONS::= $(AZURE_APP_REGIONS)"
echo "AZURE_APP_SLOT::= $(AZURE_APP_SLOT)"
echo "IMG_NAME::= $(IMG_NAME)"
echo "IMG_TAG::= $(IMG_TAG)"
echo: "REGION::= $(region)"
- task: AzureWebAppContainer@1
displayName: "Deploy to $(REGION)"
continueOnError: false
inputs:
azureSubscription: $(AZURE_SUBSCRIPTION)
appName: $(AZURE_APPNAME)-$(REGION)
imageName: $(IMG_NAME):$(IMG_TAG)
deployToSlotOrASE: true
slotName: $(AZURE_APP_SLOT)
appSettings:
-WEBSITES_PORT 8003
-NODE_ENV $(NODE_ENV)
parameters.AZURE_APP_REGIONS is doesnt work. it is not splitted.
Versions
Version Dev19.M237.2 (AzureDevOps_M237_20240408.14)
Environment type (Please select at least one enviroment where you face this issue)
- Self-Hosted
- Microsoft Hosted
- VMSS Pool
- Container
Azure DevOps Server type
dev.azure.com (formerly visualstudio.com)
Azure DevOps Server Version (if applicable)
No response
Operation system
No response
Version controll system
No response
Relevant log output
No response
And it can be resolved like belows.
https://stackoverflow.com/questions/70738819/how-to-give-to-the-strategy-matrix-a-dynamic-object-based-on-the-current-filenam
just use runtime syntax. " $[ ] "
simple example.
jobs:
# Start Set Variables
- job: SetVar
pool:
name: 'Azure Pipelines'
steps:
- checkout: none
- task: Bash@3
displayName: "Set pipeline runtime variables"
continueOnError: false
inputs:
targetType: 'inline'
script: |
# Set Runtime Variables
# These Variables are pipeline variable, you have to use like $(some) instead of $some
#
echo "##vso[task.setvariable variable=azureRegionsMatrixObj;isOutput=true]$(AZURE_APP_REGIONS)"
name: outputVar
# End Set Variables
- job: deploy_service_to_slot
dependsOn: SetVar
pool:
name: 'Azure Pipelines'
strategy:
matrix: $[ dependencies.SetVar.outputs['outputVar.azureRegionsMatrixObj'] ]
steps:
- checkout: none
- task: Bash@3
displayName: "print deploy variables"
continueOnError: false
inputs:
targetType: 'inline'
script: |
# Print Variables
echo "AZURE_SUBSCRIPTION::= $(AZURE_SUBSCRIPTION)"
echo "AZURE_APPNAME::= $(AZURE_APPNAME)"
echo "AZURE_APP_SLOT::= $(AZURE_APP_SLOT)"
echo "IMG_NAME::= $(IMG_NAME)"
echo "IMG_TAG::= $(IMG_TAG)"
echo "REGION::= $(region)"
- task: AzureWebAppContainer@1
displayName: "Deploy to $(REGION)"
continueOnError: false
inputs:
azureSubscription: $(AZURE_SUBSCRIPTION)
appName: $(AZURE_APPNAME)-$(REGION)
imageName: $(IMG_NAME):$(IMG_TAG)
deployToSlotOrASE: true
slotName: $(AZURE_APP_SLOT)