Giter VIP home page Giter VIP logo

newman-docker's Introduction

newman-docker

This repository contains docker images for Newman.

Newman is a command-line collection runner for Postman. It allows you to effortlessly run and test a Postman Collections directly from the command-line. It is built with extensibility in mind so that you can easily integrate it with your continuous integration servers and build systems.

New to Docker? Docker allows you to package an application with all of its dependencies into a standardised unit for software development. Visit https://www.docker.com/whatisdocker to read more about how docker can drastically simplify development and deployment.

Using the docker image

The docker image for Newman is available for download from our docker hub. You must have Docker installed in your system. Docker has extensive installation guideline for popular operating systems. Choose your operating system and follow the instructions.

Ensure you that you have docker installed and running in your system before proceeding with next steps. A quick test to see if docker is installed correctly is to execute the command docker run hello-world and it should run without errors.

Step 1:

Pull the newman docker image from docker hub:

docker pull postman/newman_ubuntu1404

Step 2:

Run newman commands on the image:

docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/df0a40ef41d570c48154"

Build the docker image from this repository

Step 1:

Clone this repository:

git clone https://github.com/postmanlabs/newman-docker.git

Step 2:

Build the image:

docker build -t postman/newman_ubuntu1404 docker-newman/newman_ubuntu1404

Step 3:

Run a collection using the newman image:

docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/8a0c9bc08f062d12dcda"

Running local collection files

This docker image is designed to pick files from the /etc/newman directory within the image. You may mount the directory of your collection files into that location and provide the file references in standard newman parameters.

# Mount host collections folder ~/collections, onto /etc/newman on the docker image, so that newman
# has access to collections
docker run -v ~/collections:/etc/newman -t postman/newman_ubuntu_1404 --collection="HTTPBinNewmanTestNoEnv.json.postman_collection"

You are not required to mount a volume if you do not need to save newman report to the host, and your collection is available online, unless your collection requires an environment(as environments cannot be passed as URLs).

To know more about mounting volumes, visit docker documentation on shared data volumes.

Examples

Run a local collection, pass an environment to it, and save the HTML report on the host.

docker run -v ~/collections:/etc/newman -t postman/newman_ubuntu1404 \
    --collection="HTTPBinNewmanTest.json.postman_collection" \
    --environment="HTTPBinNewmanTestEnv.json.postman_environment" \
    --html="newman-results.html"


Run a remote collection, pass it a local environment, and save JUnit XML test report on the host

docker run -v ~/collections:/etc/newman -t postman/newman_ubuntu1404 \
    --url="https://www.getpostman.com/collections/8a0c9bc08f062d12dcda" \
    --environment="HTTPBinNewmanTestEnv.json.postman_environment" \
    --testReportFile="newman-report.xml"


Import a Postman backup file, and save collections, environments, and globals

docker run -v ~/collections:/etc/newman -t postman/ubuntu_1404 --import="Backup.postman_dump" --pretty


Use a script to run a collection and do something, for example deploy the build, if all the tests pass

#/bin/bash

# stop on first error
set -e;

function onExit {
    if [ "$?" != "0" ]; then
        echo "Tests failed";
        # build failed, don't deploy
        exit 1;
    else
        echo "Tests passed";
        # deploy build
    fi
}

# call onExit when the script exits
trap onExit EXIT;

docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/8a0c9bc08f062d12dcda" --exitCode;

Analytics

newman-docker's People

Contributors

czardoz avatar elssar avatar kunagpal avatar shamasis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.