Reputation: 125
I am trying to output outputStorageUri
and outputStorageContainerSasToken
from the AzureFileCopy task and consume them in a powershell script, a simple example of what I am trying to achieve is:
pool:
vmImage: 'VS2017-Win2016'
variables:
Parameters.outputStorageUri: ''
Parameters.outputStorageContainerSasToken: ''
steps:
- task: AzureFileCopy@3
inputs:
sourcePath: '$(Build.ArtifactStagingDirectory)\MyProgram.ext'
azureSubscription: 'MyAzureServiceRole'
Destination: 'AzureBlob'
storage: 'myfilestorage'
ContainerName: 'programs'
outputStorageUri: '$(Parameters.outputStorageUri)'
outputStorageContainerSasToken: '$(Parameters.outputStorageContainerSasToken)'
sasTokenTimeOutInMinutes: 5
displayName: Upload program to Blob storage
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
Write-Host 'URL = ' + $Env:PARAMETERS_OUTPUTSTORAGEURI
errorActionPreference: 'stop'
failOnStderr: 'false'
displayName: Send storage URL to Logger(s)
The file is copied correctly, however Write-Host in the example for the outputStorageUri is always blank! I have also tried a number of other ways to no avail... Please can someone enlighten me as to what I am doing wrong...
Upvotes: 2
Views: 4508
Reputation: 305
Kind of related but if you are using V4 then these are available as Output Variables. This is not there in the documentation but highlighted in this issue.
https://github.com/microsoft/azure-pipelines-tasks/issues/13246
Upvotes: 3
Reputation: 24569
We should use the name of the variable, not the variable value in the task.
Please change the $(Parameters.outputStorageUri)
to Parameters.outputStorageUri
$(Parameters.outputStorageContainerSasToken)
to Parameters.outputStorageContainerSasToken
, then it will work.
outputStorageUri: Parameters.outputStorageUri
outputStorageContainerSasToken: Parameters.outputStorageContainerSasToken
For more information please refer to Azure File Copy
provide the name of the output variable you would like to use.
Upvotes: 5