azure pipeline template fails to find script when targetType: filePath

Solution for azure pipeline template fails to find script when targetType: filePath
is Given Below:

I have an azure pipeline which runs a pipeline template which lives in a different repository … when the template executes a task: Bash@3 with an inline shell script all is well … however I want the template to execute a script local to the template repository … currently it fails to find this script when I use targetType: filePath … this script lives local to same repo directory as the pipeline template yaml file

here is my parent pipeline which lives at https://github.com/sekhemrekhutawysobekhotep/shared_variables_across_templates

cat ~/src/foo/github.com/sekhemrekhutawysobekhotep/shared_variables_across_templates/parent_own_file.yaml


pool:
  vmImage: 'ubuntu-latest'

resources:
  repositories:
  - repository: cool_templates
    type: github  #  use these flavors    git = Azure DevOps / github = GitHub
    name: sekhemrekhutawysobekhotep/pipeline-templates
    ref: main
    endpoint: sekhemrekhutawysobekhotep

trigger:
  branches:
    exclude:
      - '*'

stages:
- template: do_peach.yaml@cool_templates

above calls pipeline template do_peach.yaml which lives at https://github.com/sekhemrekhutawysobekhotep/pipeline-templates … here is that pipeline template

cat ~/src/foo/github.com/sekhemrekhutawysobekhotep/pipeline-templates/do_peach.yaml  


stages:
- stage: some_cool_template
  jobs:
  - job: launch_template_rwanda
    steps:
    - task: Bash@3
      displayName: 'now lets do some calc'
      inputs:
        targetType: filePath
        # filePath: ./do_peach.sh
        filePath: do_peach.sh

above pipeline template errors when it fails to find script do_peach.sh which lives in same repo as the do_peach.yaml

##[error]ENOENT: no such file or directory, stat '/home/vsts/work/1/s/do_peach.sh'

Here is the output of an azure pipeline run

https://dev.azure.com/sekhemrekhutawysobekhotep/public_project/_build/results?buildId=547&view=logs&j=31e0a65e-b3f0-5eb0-8d0a-15a2530340ec&t=bb044a8a-7c80-5775-3c93-f233af567bd5&l=44

My guess is I need to beef up how I specify value given to tag filePath: in above … seems this should be a common issue as I have encountered this error often and this time I do not want to put my shell script inline as it will not fit ( I get error Exceeded max expression length 21000 but that is another issue ) … doc on pipeline templates does not offer a solution … Any suggestions ?

PS I get same error when code in both repositories live as azure repos and not github

In attempt to brute force find the file do_peach.sh I ran below which failed to find the file

find $(Agent.BuildDirectory) | grep 'do_peach.sh' 


find $(Build.SourcesDirectory) | grep 'do_peach.sh' 

Please add:

- checkout: cool_templates

to download repository. Also for multiple repositories code will be in seprate folder

Multiple repositories: 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_work1 and your repositories are named tools and code, your code is checked out to C:agent_work1stools and C:agent_work1scode.