![](/img/trans.png)
[英]Environments are not automatically created in Azure Devops when declared in yaml pipeline config
[英]YAML Parser error on Azure DevOps Pipeline
我在我的 azure devop 管道上收到以下錯誤,它似乎與參數循環有關,但盡管以多種不同的方式編寫腳本,但我似乎無法擺脫它。 YAML 驗證器和我的 YAML linter 沒有檢測到問題。
/azure-pipelines.yml (Line: 1, Col: 12): Unexpected value ''
下面是我的代碼,它也使用了一個模板,我將把它包含在它下面。
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'
模板 - deploy-functions.yml
trigger:
- main
variables:
- group: 'AzFunctionsAppVariableGroup'
pool:
vmImage: ubuntu-18.04
steps:
- template: azure-pipelines.yml
parameters:
projects:
- ProjectName1
如果我將您的 azure-pipelines.yml 放入 Azure DevOps 的管道編輯器中,它會標記參數的行結尾:帶有警告
“類型不正確。應為“數組”。”
到目前為止,我還沒有在管道上使用模板,但是從MS 文檔頁面來看,您似乎需要指定要傳遞的參數,如下所示:
#azure-pipelines.yml
parameters:
- name: projects
type: object #object, since you are passing a list of strings
steps:
- ${{ each project in parameters.projects }}:
#...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.