Postman CLI GitHub Action执行Collection突然失效求助
问题:Postman CLI在GitHub Action中执行
postman api lint报错,找不到配置文件 之前一直正常运行的Postman CLI GitHub Action,近一周出现异常。Action配置如下:
runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Install Postman CLI run: | curl -o- "https://dl-cli.pstmn.io/install/linux64.sh" | sh - name: Login to Postman CLI run: postman login --with-api-key ${{ secrets.POSTMAN_API_KEY }} - name: Run API tests run: | postman collection run "14779683-c20279a2-e01b-42d7-a435-cb45a05d982c" -e "14779683-fb25fdcd-2eee-4e1a-9bc5-5c13edfef1a5" --integration-id "135195-${{ github.run_id }}" postman api lint --integration-id 135195-${{ github.run_id }}
API密钥有效,Collection测试可正常完成,但执行后出现以下错误:
Postman CLI run data uploaded to Postman Cloud successfully. You can view the run data in Postman at: https://go.postman.co/workspace/3998f5e5-fd98-4009-8cac-16dbba3f93fc/api/f79c4bd4-cf58-4ff8-9237-2f4a87135b6c/run/14779683-dcbd86b3-9124-4295-b476-03a1d7ab6768 Error: Couldn't find the Postman config file in the current directory. Try re-integrating this folder with your Postman API. https://go.pstmn.io/v10-git-local-docs
疑问:是否是Postman CLI更新导致该问题?缺少什么配置?
解决方案
- 这个错误源于
postman api lint命令需要本地存在Postman配置文件(通常是.postman/api.json),而你的GitHub Action运行环境中没有这个文件。 - 大概率是Postman CLI近期更新后,
api lint的执行逻辑发生变化,不再支持仅通过集成ID直接运行,必须依赖本地与Postman API关联的配置文件。 - 可通过以下方式解决:
- 提交本地生成的配置文件:在本地项目目录执行
postman api integrate命令,关联你的Postman API,生成.postman/api.json后将该文件提交到GitHub仓库。 - 在Action中动态生成配置文件:在Action步骤中添加初始化命令,生成所需配置文件后再执行lint:
替换为你实际的API ID和工作区ID即可。postman api init --api-id "你的API ID" --workspace-id "你的工作区ID" - 回退到稳定版本:如果不想适配新版本逻辑,可指定安装之前能正常运行的Postman CLI版本:
替换成你之前使用的具体版本号。curl -o- "https://dl-cli.pstmn.io/install/linux64.sh" | sh -s v10.17.0
- 提交本地生成的配置文件:在本地项目目录执行
内容的提问来源于stack exchange,提问作者Fima Rotter
相关产品推荐
相关产品推荐

