Newman Collection postman json - 管道 Azure Devops

问题描述 投票:0回答:1

任何人都可以告诉我如何在 Azure Devops 中的管道中将节点和 npm 的路径配置为变量 env sustem,以使 make newman 运行我的集合 postman json?

我创建了一个管道,但它不执行我的集合

MyCollection
已推送到我的存储库中,在 Azure DevOps 中

azure-devops environment-variables postman repository newman
1个回答
0
投票

根据 newman 指南,您需要在计算机上安装

Node.js >= v16
,安装 Newman 最简单的方法是使用 NPM。在 DevOps Microsoft 托管代理上,它已经预装了 Node 和 NPM,您无需配置 Node 和 npm 的路径。

Microsoft 托管代理:windows-2022 如下示例:

第一步: 只需简单地运行

npm install -g newman
即可全局安装 Newman(
-g
表示全局),它允许您从任何地方运行它。

第二步: 您可以将collection.json上传到DevOps git repo,并为newman命令指定json文件。

DevOps yaml 示例:

- script: |
   npm install -g newman
   
  workingDirectory: '$(System.DefaultWorkingDirectory)'
  displayName: 'Command Line Script'

- script: 'newman run TEST.postman_collection.json --reporters cli,junit --reporter-junit-export Results\junitReport.xml '
  workingDirectory: '$(build.sourcesdirectory)'
  displayName: 'Command Line Script

此外,还有一个扩展 Newman the cli Companion for Postman,您也可以使用它来运行 newman 命令。

steps:
- script: |
   npm install -g newman
  workingDirectory: '$(System.DefaultWorkingDirectory)'
  displayName: 'Command Line Script'


- task: NewmanPostman@4
  displayName: 'Newman - Postman'
  inputs:
    collectionFileSource: 'TEST.postman_collection.json'
    environmentSourceType: none
    ignoreRedirect: false
    bail: false
    sslInsecure: false
    htmlExtraDarkTheme: false
    htmlExtraLogs: false
    htmlExtraTestPaging: false

您可以查看类似链接供您参考。

PS:如果你使用

self-hosted
代理,你可以预装node.js和NPM,系统变量应该配置好,DevOps代理可以自动扫描它们(能力),并在任务中调用它们。

© www.soinside.com 2019 - 2024. All rights reserved.