【发布时间】:2020-05-26 23:23:42
【问题描述】:
我的目标是
- 在构建阶段通过 API 调用获取邮递员脚本
- 在测试阶段运行这些脚本
我已经完成了第 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