当 targetType : filePath 时, azure 管道模板无法找到脚本

标签 azure azure-pipelines

我有一个 azure 的管道,它运行一个位于不同存储库中的管道模板...当模板执行任务时:带有内联 shell 脚本的 Bash@3 一切都很好...但是我希望模板执行模板存储库本地的脚本...当前,当我使用 targetType: filePath 时,它无法找到该脚本...该脚本位于与管道模板 yaml 文件相同的存储库目录的本地

这是我的父管道,位于 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

上面调用了位于 https://github.com/sekhemrekhutawysobekhotep/pipeline-templates 的管道模板 do_peach.yaml ...这是管道模板

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

上述管道模板在找不到与 do_peach.yaml 位于同一存储库中的脚本 do_peach.sh 时出现错误

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

这是 azure 管道运行的输出

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

我的猜测是我需要加强如何指定标签 filePath: 的值,在上面......似乎这应该是一个常见问题,因为我经常遇到这个错误,这次我不想把我的 shell内联脚本,因为它不适合(我收到错误 Exceeded max expression length 21000 但这是另一个问题)...管道模板上的文档没有提供解决方案...有什么建议吗?

PS 当两个存储库中的代码都作为 azure 存储库而不是 github 运行时,我遇到相同的错误

为了尝试暴力查找文件 do_peach.sh,我在下面运行但未能找到该文件

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


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

最佳答案

请添加:

- checkout: cool_templates

下载存储库。此外,对于多个存储库,代码将位于单独的 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_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.

关于当 targetType : filePath 时, azure 管道模板无法找到脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68628601/

相关文章:

java - 当java编译器输出错误时如何使管道失败

azure - Azure WebJob 如何运行应用程序?

Azure 存储。收到 403 [url](未启用 CORS 或未找到此请求的匹配规则。)

azure - 服务总线通知中心 : What is the payload size limit for the push notification?

azure - 发布后如何将 Azure 数据工厂参数获取到 ARM 模板参数文件 (ARMTemplateParametersForFactory.json)

azure - 是否可以通过 Azure DevOps 通过 Linux 环境对 Azure Function 进行持续部署 CI/CD?

c# - AAD 缺少权限

c# - Azure 云服务无法将 vmsize 设置为 : ExtraSmall, Small、Medium 以外的任何值

ssh - 使用 SSH 在 Azure Pipeline 中 checkout git 子模块

azure - 逻辑应用 CI/CD - 为什么将工作流视为基础设施?