无法在 azure devops 管道中找到文件

Rei*_*jer 2 azure-devops azure-pipelines

我的目标是

\n\n
    \n
  1. 在构建阶段通过API调用获取postman脚本
  2. \n
  3. 在测试阶段运行这些脚本
  4. \n
\n\n

我已完成第 1 步,但我似乎找不到从 API 调用中提取的文件。\n这是获取邮递员脚本的 API 调用的日志:

\n\n
2020-02-11T13:54:34.8779080Z attempting to call Postman API for environment..\n2020-02-11T13:54:34.8781038Z file /home/vsts/work/1/a/postman\\EA.API.pipeline.json Saved!\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是测试阶段运行邮递员脚本步骤的结果(我尝试访问pilot.environment和EA.API.pipeline.json):

\n\n
error: ENOENT: no such file or directory, open \'/home/vsts/work/1/a/postman/environments/pilot.environment.json\'\n
Run Code Online (Sandbox Code Playgroud)\n\n

现在我考虑的一个选项是在阶段之间擦除这些目录。我在构建阶段获取脚本,并尝试在测试阶段运行它们。这就是为什么在提取脚本后,我确保它们实际上在存储中,然后我尝试将它们作为工件发布:

\n\n
========================== Starting Command Output ===========================\n/bin/bash --noprofile --norc /home/vsts/work/_temp/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx.sh\n/home/vsts/work/1/a\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 postman\\\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 postman\\EA.API.pipeline.json\n
Run Code Online (Sandbox Code Playgroud)\n\n

但在同一构建阶段的下一步中,我尝试将这些测试作为工件发布,并收到此错误:

\n\n
##[error]Path does not exist: /home/vsts/work/1/a/postman/EA.API.pipeline.json\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是 yaml:

\n\n
     - task: OneLuckiDev.getPostmanJSON.vsts-release-web-test.oneLuckiGetPostmanScripts@1\n        displayName: \'Get Postman Script\'\n        inputs:\n          fileLocation: \'$(build.artifactstagingdirectory)/postman\'\n          apiKey: \'$(PostmanAPIKey)\'\n      - script: \'sudo apt-get install tree\'\n        displayName: \'install tree\'\n      - script: \'tree "$(build.artifactstagingdirectory)"\'\n        displayName: \'run tree\'            \n      - task: PublishPipelineArtifact@1\n        displayName: \'Publish Artifact: postman API tests\'\n        inputs:\n          targetPath: \'$(build.artifactstagingdirectory)/postman/EA.API.pipeline.json\'\n          artifact: PostmanAPITests\n          publishLocation: \'pipeline\'\n
Run Code Online (Sandbox Code Playgroud)\n\n

为什么我找不到我的文件?

\n

gun*_*har 5

这似乎是你的斜线的问题。您的任务 OneLuckiDev.getPostmanJSON.vsts-release-web-test.oneLuckiGetPostmanScripts@1 似乎是为 Windows 代理编写的,但您正在使用 Linux 代理。这导致它在保存脚本时附加反斜杠,该反斜杠对于代理来说仅被视为文件名的一部分。文件 postman\EA.API.pipeline.json 是您保存的脚本。