ir2pid
ir2pid

Reputation: 6126

CircleCI save output for dependent jobs in workflow

I have two jobs, B dependant on A and I need to use it's output as input for my next job.

version: 2
jobs:
  A:
    docker:
      - image: xxx
    environment:
      MAKEFLAGS: "-i"
      JVM_OPTS: -Xmx3200m
    steps:
      - run: git submodule update --init
      - run:
          name: build A
          command: cd platform/android/ && ant
  B:
    docker:
      - image: yyy
    environment:
      MAKEFLAGS: "-i"
      JVM_OPTS: -Xmx3200m
    steps:
          name: build B
          command: ./gradlew assembleDebug

workflows:
  version: 2
  tests:
    jobs:
      - A
      - B:
          requires:
           - A

The output of job A in folder ./build/output needs to be saved and used in job B.

How do I achieve this?

Upvotes: 2

Views: 350

Answers (1)

FelicianoTech
FelicianoTech

Reputation: 4017

disclaimer: I'm a CircleCI Developer Advocate

You would use CircleCI Workspaces.

version: 2
jobs:
  A:
    docker:
      - image: xxx
    environment:
      MAKEFLAGS: "-i"
      JVM_OPTS: -Xmx3200m
    steps:
      - run: git submodule update --init
      - run:
          name: build A
          command: cd platform/android/ && ant
      - persist_to_workspace:
          root: build/
          paths:
            - output
  B:
    docker:
      - image: yyy
    environment:
      MAKEFLAGS: "-i"
      JVM_OPTS: -Xmx3200m
    steps:
      - attach_workspace:
          at: build/
          name: build B
          command: ./gradlew assembleDebug

workflows:
  version: 2
  tests:
    jobs:
      - A
      - B:
          requires:
           - A

Also keep in mind, your B job has some YAML issues.

Upvotes: 2

Related Questions