azure - 天蓝色管道模板在 targetType:filePath 时找不到脚本
问题描述
我有一个运行在不同存储库中的管道模板的 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.sh
当找不到与 do_peach.yaml 位于同一存储库中的脚本时,上述管道模板错误
##[error]ENOENT: no such file or directory, stat '/home/vsts/work/1/s/do_peach.sh'
这是天蓝色管道运行的输出
我的猜测是我需要加强我如何指定给标记文件路径的值:在上面......似乎这应该是一个常见问题,因为我经常遇到这个错误,这次我不想将我的 shell 脚本内联为它不适合(我收到错误 Exceeded max expression length 21000
,但这是另一个问题)...管道模板上的文档不提供解决方案...有什么建议吗?
PS当两个存储库中的代码都作为 azure repos 而不是 github 时,我得到同样的错误
试图蛮力找到文件 do_peach.sh 我在下面运行但找不到文件
find $(Agent.BuildDirectory) | grep 'do_peach.sh'
find $(Build.SourcesDirectory) | grep 'do_peach.sh'
解决方案
请加:
- checkout: cool_templates
下载存储库。同样对于多个存储库,代码将位于单独的文件夹中
多个存储库:如果您的作业中有多个签出步骤,您的源代码将签出到以存储库命名的目录中,作为 (Agent.BuildDirectory) 中 s 的子文件夹。如果 (Agent.BuildDirectory) 是 C:\agent_work\1 并且您的存储库被命名为 tools 和 code,那么您的代码将检出到 C:\agent_work\1\s\tools 和 C:\agent_work\1\s\code。
推荐阅读
- c - 访问 IPC_PRIVATE 生成的 key_t
- node.js - lodash 检查 object.path 是否等于值
- java - 发生错误时如何处理项目?
- java - 如何在java中获得真实的屏幕尺寸?
- adb - Appium - 将 Android 连接到 Docker 容器
- macos - 我们是否需要对框架(.framework)、dylib 和二进制文件进行公证?
- asp.net-core-webapi - Autofac创建2个服务实例
- javascript - Firestore 云功能尝试使用批处理对 Writes 和 Missing return promise 进行分组
- javascript - 使用 fetch(),从非 HTTP OK 状态码中读取响应体并捕获异常
- fipy - 使用 Mesh2D 构造函数重新创建 fipy Grid2D