I have a powershell script in my devops repository called functionapp.ps1 located in a folder called Deploy.
I have the following code line of code in my yml file :
- task: PowerShell@2
inputs:
filePath: '$(Pipeline.Workspace)/Deploy/functionapp.ps1'
When the stages are being run and it arrives to this task I get the following error:
##[error]Invalid file path 'D:\a\1\Deploy\functionapp.ps1'. A path to a .ps1 file is required.
I tried using filePath: '$(System.DefaultWorkingDirectory)/Deploy/functionapp.ps1'
I ended up having the same error. Can someone please tell me what is the issue here ?
CodePudding user response:
The default directory where your source code files are downloaded is C:\agent_work\s
and can be referenced from the build in variable $(Build.SourcesDirectory)
As a result you will need to use the below filepath on the powershell task:
filePath: '$(Build.SourcesDirectory)/Deploy/functionapp.ps1'
You could also use
filePath: '$(Pipeline.Workspace)/s/Deploy/functionapp.ps1'
If the checkout step for the self (primary) repository has no custom checkout path defined, or the checkout path is the multi-checkout default path $(Pipeline.Workspace)/s/<RepoName> for the self repository, the value of this variable will revert to its default value, which is $(Pipeline.Workspace)/s
A list with the build in variables can be found from the below URL:
https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
