# Executors persistence

**URL:** <https://discuss.circleci.com/t/executors-persistence/30527>\
**Category:** Build Environment\
**Created:** [May 23, 2019, 2:39pm UTC](https://discuss.circleci.com/t/executors-persistence/30527 "2019-05-23T14:39:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tristancaron](https://avatars.discourse-cdn.com/v4/letter/t/b4bc9f/32.png) [@tristancaron](https://discuss.circleci.com/u/tristancaron)\
**Post date:** [May 23, 2019, 2:39pm UTC](https://discuss.circleci.com/t/executors-persistence/30527/1 "2019-05-23T14:39:58Z")

</div>

Hello,

I have a workflow with 3 jobs; `build`, `test`, `pkg-and-deploy`. When `build` succeed, I want to run `test`. Which is happening, however I get `npm not found`. Is it because the changes I did on the machine are not preserved when changing jobs even within the same workflow?

Here my config file:

```auto
version: 2.1
executors:
  orion:
    docker:
      - image: ubuntu:18.04
      - image: mysql:5.7.21
        environment:
          - MYSQL_ROOT_PASSWORD=admin
    working_directory: /tmp/build

jobs:
  build:
    executor: orion
    steps:
      - run:
          name: 'Update APT packages'
          command: apt-get -y update > /dev/null
      - run:
          name: 'Install Git for checkout'
          command: apt-get -y install git openssh-client > /dev/null
      - run:
          name: 'Install NodeJS and MySQL'
          command: |
            apt-get install -y curl apt-transport-https > /dev/null
            curl -sL https://deb.nodesource.com/setup_11.x | bash -
            apt-get update
            apt-get install -y nodejs mysql-client > /dev/null
      - checkout
      - run:
          name: 'Initiate MySQL'
          command: mysql --user=root --password=admin --host=127.0.0.1 < docker/mysql/schema.sql
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: 'Install npm'
          command: npm install
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - node_modules
  test:
    executor: orion
    steps:
      - checkout
      - run:
          name: 'Run tests'
          command: npm test
      - store_artifacts:
          path: coverage

  pkg-and-deploy:
    executor: orion
    steps:
      - checkout
      - run:
          name: 'Build and package'
          command: |
            npm run pkg
      - deploy:
          name: 'Deploy'
          command: |
            if ["${CIRCLE_BRANCH}" == "master"]; then
              # install utils
              apt-get -y install jq curl unzip tar gzip > /dev/null
              curl -LO https://github.com/tcnksm/ghr/releases/download/v0.5.4/ghr_v0.5.4_linux_amd64.zip
              unzip *.zip
              # define version
              VERSION=$(jq -r '.version' package.json)
              export COMMIT=$(git rev-parse --short $CIRCLE_SHA1)
              # deploy
              mkdir -p deploy
              mv dist/*.tgz deploy/
              # release
              ./ghr -u Company -t $GITHUB_TOKEN -c $CIRCLE_SHA1 -delete -prerelease ${VERSION}+${COMMIT} deploy/
            fi

workflows:
  version: 2
  deploy:
    jobs:
      - build
      - test:
          requires:
            - build
      - pkg-and-deploy:
          context: 'bm-deploy'
          requires:
            - build
            - test
          filters:
            branches:
              only: master

```

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [May 23, 2019, 2:42pm UTC](https://discuss.circleci.com/t/executors-persistence/30527/2 "2019-05-23T14:42:37Z")

</div>

Each job runs in a clean container. If you want to carry data between them, Workspaces should help.

[https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs](https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs)

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [May 23, 2019, 5:10pm UTC](https://discuss.circleci.com/t/executors-persistence/30527/3 "2019-05-23T17:10:59Z")

</div>

If you want to preserve installed software across jobs, then you may be better off with a custom Docker build. Inherit from `ubuntu:18.04` (or whatever other image you prefer) and create a fresh pipeline to ensure this is always healthy.

Try @drazisil’s approach first though, as it is less work to set up.
