My code has multiple checkout's and when I run the pipeline, the directory path is not recognized for one of the checkout.
jobs:
- job: job1
steps:
- checkout: rep1
path: test1
- checkout: rep2
path: test2
- task: AzurePowerShell@5
inputs:
azureSubscription:xxxxx
ScriptType: 'FilePath'
ScriptPath: '$(System.DefaultWorkingDirectory)/folder1/myPowershell.ps1'
azurePowerShellVersion: 'LatestVersion'
I see a warning which says "Module path not present as expected in hosted agent, skipping step to make module available". The Powershell script is never executed. Any help, please?
CodePudding user response:
According to the official docs:
If you have multiple checkout steps in your job, your source code is checked out into directories named after the repositories as a subfolder of
sin(Agent.BuildDirectory). If(Agent.BuildDirectory)isC:\agent\_work\1and your repositories are namedtoolsandcode, your code is checked out toC:\agent\_work\1\s\toolsandC:\agent\_work\1\s\code.
So, it looks like the ScriptPath property of AzurePowerShell@5 task in your pipeline should be built keeping this in mind. If the PowerShell file resides in folder1 directory of the repository rep1, then the path should look like
$(Agent.BuildDirectory)/rep1/folder1/myPowershell.ps1.
