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

时间:2020-02-11 14:11:09

标签: azure-devops azure-pipelines

我的目标是

  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!

这是测试阶段运行邮递员脚本步骤的结果(我尝试同时访问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'

为什么找不到我的文件?

1 个答案:

答案 0 :(得分:2)

这似乎与您的斜杠有关。您的任务OneLuckiDev.getPostmanJSON.vsts-release-web-test.oneLuckiGetPostmanScripts@1似乎是为Windows代理编写的,但是您正在使用Linux代理。这将导致在将脚本保存到代理中时,脚本后面会附加一个反斜杠,这只是文件名的一部分。文件postman \ EA.API.pipeline.json是您保存的脚本。