version: 2
jobs:
  environment:
    GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
    _JAVA_OPTIONS: "-Xms512m -Xmx1024m"
  build:
    docker:
      - image: circleci/openjdk:8-node-browsers
    steps:
      - checkout
      - run:
          name: Download dependencies
          command: ./gradlew dependencies
      - save_cache:
          key: dependency-cache-{{ checksum "build.gradle" }}
          paths:
            - ~/.gradle
  test:
    docker:
      - image: circleci/openjdk:8-node-browsers
    steps:
      - checkout
      - restore_cache:
          key: dependency-cache-{{ checksum "build.gradle" }}
      - run:
          name: Run tests
          command: ./gradlew test
  deploy:
    docker:
      - image: buildpack-deps:trusty
    steps:
      - checkout
      - run:
          name: Deploy master to Heroku
          command: |
            git push https://heroku:$HEROKU_API_KEY@git.heroku.com/tuleva-onboarding-service.git master

workflows:
  version: 2
  build-test-and-deploy:
    jobs:
      - build
      - test:
          requires:
            - build
      - deploy:
          requires:
            - test
          filters:
            branches:
              only: master

version: 2
jobs:
  build:
    environment:
      GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
      _JAVA_OPTIONS: "-Xms512m -Xmx1024m"
    docker:
      - image: circleci/openjdk:8-node-browsers
    steps:
      - checkout
      - run:
          name: Download dependencies
          command: ./gradlew dependencies
      - save_cache:
          key: dependency-cache-{{ checksum "build.gradle" }}
          paths:
            - ~/.gradle
  test:
    environment:
      GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
      _JAVA_OPTIONS: "-Xms512m -Xmx1024m"
    docker:
      - image: circleci/openjdk:8-node-browsers
    steps:
      - checkout
      - restore_cache:
          key: dependency-cache-{{ checksum "build.gradle" }}
      - run:
          name: Run tests
          command: ./gradlew test
  deploy:
    docker:
      - image: buildpack-deps:trusty
    steps:
      - checkout
      - run:
          name: Deploy master to Heroku
          command: |
            git push https://heroku:$HEROKU_API_KEY@git.heroku.com/tuleva-onboarding-service.git master

workflows:
  version: 2
  build-test-and-deploy:
    jobs:
      - build
      - test:
          requires:
            - build
      - deploy:
          requires:
            - test
          filters:
            branches:
              only: master

Move environment keys under jobs
Move environment keys under jobs
