【问题标题】:cannot locate file in azure devops pipeline在 azure devops 管道中找不到文件
【发布时间】:2020-05-26 23:23:42
【问题描述】:

我的目标是

  1. 在构建阶段通过 API 调用获取邮递员脚本
  2. 在测试阶段运行这些脚本

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

2020-02-11T13:54:34.8779080Z attempting to call Postman API for environment..
2020-02-11T13:54:34.8781038Z file /home/vsts/work/1/a/postman\EA.API.pipeline.json Saved!

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

error: ENOENT: no such file or directory, open '/home/vsts/work/1/a/postman/environments/pilot.environment.json'

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

========================== Starting Command Output ===========================
/bin/bash --noprofile --norc /home/vsts/work/_temp/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx.sh
/home/vsts/work/1/a
├── postman\
├── postman\EA.API.pipeline.json

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

##[error]Path does not exist: /home/vsts/work/1/a/postman/EA.API.pipeline.json

这是yaml:

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

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

【问题讨论】:

  • 如果您发布整个 $(build.artifactstagingdirectory) 您在工件中看到了什么?
  • 我同意 gungthar 的回答。是你使用Linux代理造成的,从日志中也可以看到EA.API.pipeline.json文件的路径是/home/vsts/work/1/a/postman\EA.API.pipeline.json。因此,在您的发布任务中,您应该将您的 targetpath 值更改为 $(build.artifactstagingdirectory)/postman\EA.API.pipeline.json

标签: azure-devops azure-pipelines


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-08
    • 2021-12-29
    • 1970-01-01
    • 1970-01-01
    • 2021-12-02
    • 2022-12-09
    • 2021-06-14
    相关资源
    最近更新 更多