Can I build and deploy at different jobs?

Hi.
Can I build and deploy at different jobs?

I want to build at nodejs image and deploy it at python image.
I build it, but deploy job has no build files.

version: 2
jobs:
  build:
    docker:
      - image: circleci/node:8
    working_directory: ~/repo
    steps:
      - checkout

      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package.json" }}
          - v1-dependencies-
      - run:
          name: npm install
          command: |
            npm install
      - run:
          name: build
          command: |
            npm run build:dev2
      - save_cache:
          paths:
          - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

  deploy: # @see https://circleci.com/docs/2.0/deployment-integrations/#aws
    docker:
      - image: circleci/python:2.7-jessie
    working_directory: ~/repo
#    working_directory: ~/circleci-docs
    steps:
      - checkout

      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "package.json" }}
            - v1-dependencies-
      - run:
          name: Install awscli
          command: sudo pip install awscli
      - run:
          name: Deploy to S3
          command: bash bin/deploy.sh

workflows:
  version: 2
  deploy-master:
    jobs:
      - build
#      - deploy
      - deploy:
          requires: # stop when build fails
            - build

Thanks!

Hello @yousan
You want Workspaces.

Use workspaces to pass along data that is unique to this run and which is needed for downstream jobs. Workflows that include jobs running on multiple branches may require data to be shared using workspaces. Workspaces are also useful for projects in which compiled data are used by test containers.

1 Like

Thanks @KyleTryon
I try Workspaces!

Thanks @KyleTryon

I can build and deploy with workspaces :wink:

1 Like

Awesome :smiley: We’ll mark this as closed. Let us know if we can help with anything else!

1 Like