Azure 管道中的 Pytest 看不到特定文件?

Pytest in Azure pipeline does not see specific files?

我有一个 src 目录,其中包含一个 pyproject.toml,就在我的 setup.py 旁边(我 可以 找到,因为事实)。

但是当我运行任务

- bash: pytest -c src/pyproject.toml
  displayName: Run tests
  workingDirectory: $(Pipeline.Workspace)

我得到 FileNotFoundError: [Errno 2] No such file or directory: '/home/vsts/work/1/src/pyproject.toml'

无需尝试从 pytest 指向此文件,一切正常。为什么?同样的设置在本地工作正常。

workingDirectory 应该是 $(System.DefaultWorkingDirectory),而不是 $(Pipeline.Workspace)

$(Pipeline.Workspace) 是代理上的本地路径,给定构建管道的所有文件夹都是在其中创建的

$(System.DefaultWorkingDirectory) 是代理上的本地路径下载源代码文件的地方

单击 this document 了解有关 Azure DevOps 中预定义变量的详细信息