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

cat ~/src/foo/

  vmImage: 'ubuntu-latest'

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

      - '*'

- template: do_peach.yaml@cool_templates

above calls pipeline template do_peach.yaml which lives at … here is that pipeline template

cat ~/src/foo/  

- stage: some_cool_template
  - job: launch_template_rwanda
    - task: Bash@3
      displayName: 'now lets do some calc'
        targetType: filePath
        # filePath: ./

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

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

Here is the output of an azure pipeline run

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 I ran below which failed to find the file

find $(Agent.BuildDirectory) | grep '' 

find $(Build.SourcesDirectory) | grep '' 

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.