Home > other >  Mutiple repositories checkout issue in Azure Devops
Mutiple repositories checkout issue in Azure Devops

Time:10-17

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 s in (Agent.BuildDirectory). If (Agent.BuildDirectory) is C:\agent\_work\1 and your repositories are named tools and code, your code is checked out to C:\agent\_work\1\s\tools and C:\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.

  • Related