I'm getting the following error on my azure devop pipeline, it seems to relate towards parameters loop but despite writing the script multiple different ways I can't seem to get rid of it. YAML validators and my YAML linter don't detect an issue.
/azure-pipelines.yml (Line: 1, Col: 12): Unexpected value ''
Below is my code, it uses a template as well, which I will include beneath it.
azure-pipelines.yml
parameters:
steps:
- ${{ each project in parameters.projects }}:
- task: UsePythonVersion@0
displayName: 'Setting python version to 3.7'
inputs:
versionSpec: '3.7'
architecture: 'x64'
- script: |
pushd '$(System.DefaultWorkingDirectory)/${{ project }}'
pip install -r requirements.txt
displayName: 'Install prerequisites'
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/${{ project }}'
includeRootFolder: false
archiveFile: '$(System.DefaultWorkingDirectory)/${{ project }}.zip'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)/${{ project }}.zip'
artifactName: 'drop'
- task: AzureResourceManagerTemplateDeployment@3
displayName: 'ARM Template deployment: Resource Group scope'
inputs:
azureResourceManagerConnection: $(serviceConnectionName)
subscriptionId: $(subscriptionId)
resourceGroupName: $(resourceGroupName)
location: $(resourceGroupLocation)
csmFile: 'deployment_template.json'
overrideParameters: '-appName ${{ project }} -storageAcctName $(storageAcctName) -hostingPlanName $(hostingPlanName)'
- task: AzureFunctionApp@1
inputs:
azureSubscription: $(serviceConnectionName)
appType: functionAppLinux
appName: ${{ project }}
package: '$(System.DefaultWorkingDirectory)/${{ project }}.zip'
Template - deploy-functions.yml
trigger:
- main
variables:
- group: 'AzFunctionsAppVariableGroup'
pool:
vmImage: ubuntu-18.04
steps:
- template: azure-pipelines.yml
parameters:
projects:
- ProjectName1
CodePudding user response:
If I throw your azure-pipelines.yml into the pipeline editor in Azure DevOps, it marks the line ending of parameters: with the warning
"Incorrect type. Expected "array"."
I didn't work with templates on pipelines so far, but from the MS doc page, it seems that you need to specify the parameters that you are passing like so:
#azure-pipelines.yml
parameters:
- name: projects
type: object #object, since you are passing a list of strings
steps:
- ${{ each project in parameters.projects }}:
#...
CodePudding user response:
It's suggested that you could enable the feature of YAML template editor with picture below and process the test. preview features Yaml template editor