Last active
          January 29, 2023 20:20 
        
      - 
      
 - 
        
Save arifsuhan/eb25302a9215d44dbb492be4e0f289f6 to your computer and use it in GitHub Desktop.  
    Postman Collection with Newman Runner in Docker
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | version: "3.0" | |
| services: | |
| webservice: | |
| tty: true | |
| build: . | |
| ports: | |
| - 8080:8080 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | FROM alpine | |
| RUN apk add --update npm | |
| RUN npm install -g newman http-server newman-reporter-htmlextra | |
| COPY file/ run/ | |
| WORKDIR run | |
| RUN newman run Reqres_MW.json -e Reqres_Env.json -r htmlextra --reporter-htmlextra-title 'Reqres_report' --reporter-htmlextra-export "newman/index.html" | |
| WORKDIR newman | |
| EXPOSE 8080 | |
| Entrypoint ["http-server"] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | collection_Json=$1 | |
| env_Json=$2 | |
| report_name="Automate Postman Test Reporting" | |
| #------------------------------------ run postman using docker ---------------------------------- | |
| docker pull postman/newmain | |
| # docker pull postman/newman:ubuntu | |
| # docker pull postman/newman:alpine | |
| # docker run -v ~/postman:/etc/newman -t postman/newman run $collection_Json -e $env_Json | |
| docker run -v ~/postman:/etc/newman --entrypoint /bin/sh -t postman/newman -c "npm install -g newman-reporter-htmlextra;newman run $collection_Json -e $env_Json -r htmlextra --reporter-htmlextra-title '$report_name' " | |
| -------------------------------------------------------------------------------------------------------------- | |
| collection_Json=$1 | |
| env_Json=$2 | |
| report_name="Automate Postman Test Reporting" | |
| # get docker image | |
| docker pull postman/newmain | |
| # create newman container instance, run postman collection and get test report | |
| docker run -v ~/postman:/etc/newman --entrypoint /bin/sh -t postman/newman -c "npm install -g newman-reporter-htmlextra;newman run $collection_Json -e $env_Json -r htmlextra --reporter-htmlextra-title '$report_name' " | |
| # run server to see report | |
| python -m http.server 8080 | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment