I want to move some powershell script tasks to templates.
According to the Microsoft article Checkout path i need to use the different pathes in case of the single and multi repositories
#Task for the multi repo checkouts
- task: PowerShell@2
displayName: Test
inputs:
pwsh: true
targetType: filePath
filePath: ./RepoName/Script.ps1
#Task for the single repo checkout
- task: PowerShell@2
displayName: Test
inputs:
pwsh: true
targetType: filePath
filePath: ./Script.ps1
For the template we have a posibility to call it from the specified repo
- checkout: self
- checkout: repo2
- template: template.yml@self
Is it possible to have a similar way for the powershell task and call the Powershell task from the same repo as a template?
Have a possibility to call the powershell script file from the same repo as a template.
As of now, there appears to be no automatic way to detect from which repository resource the template is expanded and execute the script under the corresponding path on the agent, when we checkout multiple repos.
However, we can opt to specify the
path
for a checkout step, and the code from repository resources will be downloaded to the path relative toAgent.BuildDirectory
. The subfolder name is thus set as well with the name we defined rather thanRepoName
, even when we only checkout single repo resource. Kindly refer to the sample below.Hope the workaround may help address your concerns.