无法将输出变量获取到部署作业中

Can't Get Output Variable into Deployment Job

我一整天都在尝试各种组合。我有一个包含一系列任务的工作,最后我创建了两个我希望我的部署工作使用的输出变量。无论我做什么,部署作业中的 echo contiainername 行总是 returns 空白。

jobs:
- job: 'CreateAPMTemplates'
  displayName: 'Create APM templates'
  steps:
  - task: PowerShell@2
    inputs:
      targetType: inline
      script: (Invoke-WebRequest ifconfig.me/ip).Content.Trim()

  - task: AzureCLI@2
    displayName: 'Extract templates from Lab subscription'
    inputs:    
      azureSubscription: 'xxxxxxxx'
      scriptType: ps
      scriptLocation: inlineScript
      workingDirectory: 'xxxxxxxx'
      inlineScript: 'dotnet run extract --sourceApimName xxxxxx'
    
  - task: PublishBuildArtifacts@1
    displayName: 'Publish templates artifacts'
    condition: succeededOrFailed()
    inputs:  
      PathtoPublish: 'xxxxx'
      ArtifactName: 'templates'
      publishLocation: 'Container'

  - task: AzureFileCopy@3
    displayName: Copy deployment artifacts to the storage account
    inputs:
      sourcePath: 'xxxxxx'
      azureSubscription: 'xxxxxxx'
      destination: azureBlob
      storage: xxxxxx
      containerName: xxxxxx
      cleanTargetBeforeCopy: true
      outputStorageUri: al
      outputStorageContainerSasToken: alSasToken
      sasTokenTimeOutInMinutes: 30

  - powershell: echo "##vso[task.setvariable variable=outputContainerLocation; isOutput=true]$(al)"
    name: setContainerLocationVar

  - script: echo "$(outputContainerLocation)"
    name: echovar

  - powershell: echo "##vso[task.setvariable variable=outputSasToken; isOutput=true]$(alSasToken)"
    name: setSasTokenVar

  - script: echo "$(outputSasToken)"
    name: echovar2

- deployment: Deployment  
  displayName: 'Deploy APM templates'
  dependsOn: 'CreateAPMTemplates'
  condition: succeededOrFailed() 
  environment: 'dev'   
  variables:
    - name: containerLocation
      value: $[ dependencies.CreateAPMTemplates.outputs['setContainerLocationVar.outputContainerLocation'] ]
  strategy:
   runOnce:
    deploy:           
     steps:
      - script: echo "$(containerLocation)"
      - task: AzureResourceManagerTemplateDeployment@3
        displayName: 'Deploy APIM Products'
        inputs:    
          deploymentScope: 'Resource Group'
          azureResourceManagerConnection: 'yyyyyy'
          subscriptionId: 'yyyyyyy'
          action: 'Create Or Update Resource Group'
          resourceGroupName: 'yyyyyy'
          location: 'West Europe'
          templateLocation: 'Linked artifact'
          csmFile: 'yyyyyyyyyy'
          csmParametersFile: 'yyyyyyyyyy'
          deploymentMode: 'Incremental'
          overrideParameters: '-ApimServiceName yyyyyyyyyy -LinkedTemplatesBaseUrl $(al) -LinkedTemplatesSasToken $(alSasToken)'

知道我做错了什么吗?在部署作业中,我尝试了以下排列来获取输出变量。

dependencies.CreateAPMTemplates.outputs['CreateAPMTemplates.setContainerLocationVar.outputContainerLocation'] ]

dependencies.CreateAPMTemplates.outputs['setContainerLocationVar.outputContainerLocation'] ]

dependencies.CreateAPMTemplates.outputs['outputContainerLocation'] ]

所以我想通了这个问题。我不确定这是否在 Microsoft 的文档中,但是当您设置变量时,请勿在分号和 isOutput 标志之间放置 space,例如

- powershell: echo "##vso[task.setvariable variable=outputContainerLocation;isOutput=true]some value"
  name: setContainerVarStep

不好

- powershell: echo "##vso[task.setvariable variable=outputContainerLocation; isOutput=true]some value"
  name: setContainerVarStep