sudo: true
dist: trusty

before_install:
  - docker --version

env:
  - IMAGE_NAME: docker-pipeline
    RELEASE_URL: https://registry.hub.docker.com/u/stevencooney/docker-test/trigger/$DOCKER_HUB_TOKEN/

jobs:
  include:
    - stage: build docker image
      script:
      - docker build --pull -t $IMAGE_NAME .
      - docker images
    - stage: test docker image
      script: docker run -i $IMAGE_NAME /bin/sh -c 'docker --version'
    - script: docker run -i $IMAGE_NAME /bin/sh -c 'docker --version'
sudo: true
dist: trusty

before_install:
  - docker --version

env:
  - IMAGE_NAME: docker-pipeline
    RELEASE_URL: https://registry.hub.docker.com/u/stevencooney/docker-test/trigger/$DOCKER_HUB_TOKEN/

jobs:
  include:
    - stage: build & test docker image
      script:
      # Build docker image
      - docker build --pull -t $IMAGE_NAME .
      - docker images
      # Test docker image
      - docker run -i $IMAGE_NAME /bin/sh -c 'docker --version'

Move test and build within the same stage.
Move test and build within the same stage.

This allows the docker image to be persisted within stages.
