0
votes

I have a task in my Yaml pipeline to upload artifacts in Blob Storage. I was able to do it for Windows agent using AZ File Copy task(shown below) but it failed for Linux and Mac agent. I was suggested here to use Azure CLI task instead to make it work with Linux and Mac agent. Below is the Azure Cli task which I have written but it fails saying error as "[error]Script failed with error: Error: Unable to locate executable file: 'powershell'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable. "

I would like some help in framing the Azure Cli task in proper way which corresponds to my Azure File copy task. here are both tasks. Please suggest what wrong am I doing?

- task: AzureFileCopy@2
          displayName: 'Publish to Blob'
          inputs:
            SourcePath: '$(Build.SourcesDirectory)/ABC-$(osSuffix)'
            azureSubscription: 'Azure CICD'
            Destination: AzureBlob
            storage: '$(BlobStorageAccount)'
            ContainerName: '$(BlobContainer)'
            BlobPrefix: '$(BlobPrefix)/ABC/$(DeploymentVersion)/ABC-$(osSuffix)'
            AdditionalArgumentsForBlobCopy: '/V /S'
            outputStorageUri: BlobUri
            outputStorageContainerSasToken: BlobSASToken



task: AzureCLI@2
          displayName: PublishToBlob
          inputs:
            azureSubscription: 'Azure CICD'
            scriptType: 'ps'
            scriptLocation: 'inlineScript'
            inlineScript: 'az storage blob upload -f '$(Build.SourcesDirectory)/ABC-$(osSuffix)' -c '$(BlobContainer)' -n '$(BlobPrefix)/ABC/$(DeploymentVersion)/ABC-$(osSuffix)'' 


      
1

1 Answers

1
votes

Finally figured it out: Here you go:

- task: AzureCLI@2
          displayName: PublishToBlob
          inputs:
            azureSubscription: 'Azure CICD'
            scriptType: 'pscore'
            scriptLocation: 'inlineScript'
            inlineScript: az storage blob upload-batch -d "$(BlobContainer)/ABC/$(DeploymentVersion)/ABC-$(osSuffix)" --account-name "mystorageaccount" -s "$(Build.SourcesDirectory)/ABC-$(osSuffix)"