0
votes

I wrote an Azure PowerShell task in the Azure DevOps YAML pipeline as given below

  - task: AzurePowerShell@3
    displayName: 'Invoke Test'
    inputs:
     azureSubscription: 'subscriptionname'
     ScriptPath: '$(Build.SourcesDirectory)\ProjectName\Scripts\Build\TestRelease.ps1'
     ScriptArguments: -testfilepath '$(Build.SourcesDirectory)\ProjectName\Releases\test.json -JsonFilepath '$(Build.SourcesDirectory)\test\qa\test_qa.json' -AzuredevopsService $(AzuredevopsService) -Verbose
     azurePowerShellVersion: LatestVersion

Even though the pipeline job is getting executed successfully the above PowerShell task is not executing and getting the log as given below. The same PowerShell script when I am calling from classic editor pipeline it is working

  ## Initializing Azure Complete
  ## Beginning Script Execution
  & 'C:\devops\vsts-agent-win-x64-2.154.3\_work\10\s\ProjectName\Scripts\Build\TestRelease.ps1' -testfilepath 'C:\devops\vsts-agent-win-x64-2.154.3\_work\10\s\ProjectName\Releases\test.json' -JsonFilepath 'C:\devops\vsts-agent-win-x64-2.154.3\_work\10\s\test\qa\test_qa.json' -AzuredevopsService https://test.azure.com -organisation OrgName -Verbose
 ## Script Execution Complete
1

1 Answers

0
votes

There seems to be a problem with your YAML. Please remove the single quotes (') of the path in ScriptArguments.

So, the task settings should be as follows:

- task: AzurePowerShell@3
  displayName: 'Invoke Test'
  inputs:
    azureSubscription: 'subscriptionname'
    ScriptPath: '$(Build.SourcesDirectory)\ProjectName\Scripts\Build\TestRelease.ps1'
    ScriptArguments: '-testfilepath $(Build.SourcesDirectory)\ProjectName\Releases\test.json -JsonFilepath $(Build.SourcesDirectory)\test\qa\test_qa.json -AzuredevopsService $(AzuredevopsService) -Verbose'
    azurePowerShellVersion: 'LatestVersion'

If that still doesn't work, please try other versions of that task. For example:

- task: AzurePowerShell@5
  displayName: 'Invoke Test'
  inputs:
    azureSubscription: 'subscriptionname'
    ScriptType: 'FilePath'
    ScriptPath: '$(Build.SourcesDirectory)\ProjectName\Scripts\Build\TestRelease.ps1'
    ScriptArguments: '-testfilepath $(Build.SourcesDirectory)\ProjectName\Releases\test.json -JsonFilepath $(Build.SourcesDirectory)\test\qa\test_qa.json -AzuredevopsService $(AzuredevopsService) -Verbose'
    azurePowerShellVersion: 'LatestVersion'