![](/img/trans.png)
[英]Test script is failing when executed via Newman in Jenkins while works fine in postman and no postman console error comes
[英]Run multiple postman collections using newman on Jenkins
我在 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。
提前致謝!
我在嘗試運行 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 作業的結果。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.