Azure Pipelines. Run script from resource repo

Viewed 1634

I have yaml file for the azure pipline in a repo. And I need to run powershell script from a different repo.

As far as I understood I can add side repo to resources section in yaml and then use task:ShellScript@2 with scriptPath parameter. But as I understood it works relatively for repo in which yaml is placed. And I'm not sure how can I access file from a different repo.

1 Answers

Yes, you have to use repository resource and checkout that repo as follows:

resources:
  repositories:
    - repository: devops
      type: github
      name: kmadof/devops-templates
      endpoint: kmadof


steps:
- checkout: self
- checkout: devops
- task: ShellScript@2
  inputs:
    scriptPath: $(Agent.BuildDirectory)/devops/scripts/some-script.sh
Related