Newman API 테스트 컬렉션을 Jenkins와 통합하고 Flock 메신저를 사용하여 보고서 게시
In this article, we will be exploring about how to run Postman collections on Jenkins with Freestyle Project. And we will try to generate our test run reports using Allure Jenkins plugin and will publish the test run status notifications to Flock messenger.
내용물
Jenkins Setup
젠킨스 설정
Before we get started, you’ll need to install Jenkins on your machine. If you don’t have a setup Jenkins on your machine please follow this official documentation .Jenkins를 설치한 후 Jenkins에서 NodeJS를 구성해야 합니다.
1단계: NodeJS 플러그인 설치:
Go to → Manage Jenkins → Select Manage Plugins → Select Available tab and Search Active Choice Plugin.
플러그인의 올바른 설치를 위해 Jenkins를 설치하고 다시 시작하십시오.
2단계: NodeJS에 Newman 및 Allure 패키지 추가
Open Jenkins: Manage Jenkins → Global Tool Configuration → NodeJS
Set your compatible node version. We can set multiple NodeJS versions for multiple applications.
Make sure you follow these steps:
- Check the “Install automatically” option
- Select compatible Node version (NodeJs-16.2.0)
- Add required packages in the “Global Packages to Install” section In our case, add the following packages newman newman-reporter-allure
- Save settings.
3단계: 자유형으로 Newman 작업을 만듭니다.
1. Create a Freestyle job to execute Newman collections scripts.
Open Jenkins → New Item → Enter any job name→ Choose Freestyle Project → Click on Save button
A build parameter allows us to pass data into our Jenkins jobs. Build parameters are a powerful way to make any Jenkins job more dynamic.So by using build parameters, we can pass any data we want. In our use case, we will be passing the Newman environment variables. Note: Follow this tutorial , Newman 환경 변수의 고유 ID를 얻으려면.
Extended Choice Parameter 플러그인 설치:
General → Check “This project is parameterized” → Add parameter → Choice parameter → add respective choice values for parameterization [QA / Prod].
3.Source Code Management → Check “None”
4.Build environment → Check “Delete workspace before build starts”
5.Build environment → Check “Provide Node & npm bin/ folder to PATH” → select NodeJs name
6.Build → Add build step → Select Execute Shell → And Paste the below code. → Save Your config.
eg:- newman run [collections] -e [environment] -r allure --reporter-allure-export target/allure-results --suppress-exit-code 1
newman run "https://api.getpostman.com/collections/[collection_uid]?apikey=[apiKey]" \
--environment "https://api.getpostman.com/environments/$server?apikey=[apiKey]" \
-r allure --reporter-allure-export target/allure-results \
-- suppress-exit-code 1
참고: 고유 컬렉션 ID 및 API 키를 사용하여 셸 명령을 통해 Newman을 실행하려면 다음tutorial을 따르세요.
Allure 및 Flock 플러그인 설치
7.Post Build Action → Allure Report → Add Path (“target/allure-results”)
모든 성공적인 빌드 및 보고서 파일이 지정된 $PATH 아래에 배치된 후 Allure 보고서가 생성됩니다.8.Post Build Action → Send Flock Notification (add flock webhook URL)
Webhook URL을 생성하려면 이 가이드를 따르십시오.
실행 방법
Now we just have to build our job to execute our tests. And we can do so by clicking on the “Build with Parameters” button on the left side of the dashboard.
In this article we have seen how to use Jenkins to run Newman tests, generate & publish reports using Allure / Flock plugins. I hope you may have found this useful. Cheers!!
Reference
이 문제에 관하여(Newman API 테스트 컬렉션을 Jenkins와 통합하고 Flock 메신저를 사용하여 보고서 게시), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/abusithik/integrating-newman-api-test-collections-with-jenkins-and-publish-reports-using-flock-messenger-57cm텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)