【问题标题】:Run multiple postman collections using newman on Jenkins在 Jenkins 上使用 newman 运行多个邮递员集合
【发布时间】:2019-12-14 09:22:47
【问题描述】:

我在 Jenkins Pipeline 作业中使用以下命令:

sh "postman-combine-collections -f *.postman_collection.json -o out.collection.json"

sh "newman run out.collection.json -e apigee-${params.Environment}-environment.postman_environment.json"

它总是只运行第一个集合。

我正在使用 Postman-combine-collections v1.1.0。

提前致谢!

【问题讨论】:

    标签: jenkins-pipeline postman jenkins-groovy newman


    【解决方案1】:

    我在尝试一次又一次地运行 newman 两次时遇到了同样的问题。我想使用两个不同的环境文件。如果 newman 退出失败(退出代码!= 0),Jenkins 作业将停止。

    如果使用 -x (--suppress-exit-code),则执行第二次运行。不幸的是,这样第一次运行的退出代码设置为 0。第一次运行失败的测试不会导致 Jenkins 作业失败。

    这是我的解决方案:

    sh """
        set +e
    
        newman run collection.json -e environment01.json
        if [ $? != 0 ]
        then
            newman run collection.json -e environment02.json
            exit 1
        else
            newman run collection.json -e environment02.json
        fi
    """
    

    通过明确定义“set +e”,Jenkins 继续失败。如果第一次运行的退出代码不为零,那么无论第二次运行得到什么结果,Jenkins 都会以返回代码 1 退出。尽管两次运行都已执行。如果第一次运行成功,则第二次运行将确定 Jenkins 作业的结果。

    【讨论】:

      猜你喜欢
      • 2018-09-23
      • 2019-03-28
      • 2018-05-22
      • 2016-07-24
      • 2017-02-11
      • 1970-01-01
      • 2018-04-20
      • 2017-11-03
      • 2018-01-11
      相关资源
      最近更新 更多