How can I set gradle/test to work on the same docker environment where other CircleCi jobs are running

144 Views Asked by At

I have a CircleCi's workflow that has 2 jobs. The second job (gradle/test) is dependent on the first one creating some files for it. The problem is with the first job running inside a docker, and the second job (gradle/test) is not. Hence, the gradle/test is failing since it cannot find the files the first job created. How can I set gradle/test to work on the same space?

Here is a code of the workflow:

version: 2.1

orbs: 
  gradle: circleci/[email protected]

executors:
  daml-executor:
    docker:
      - image: cimg/openjdk:11.0-node

...

workflows:
  checkout-build-test:
    jobs:
      - daml_test:
          daml_sdk_version: "2.2.0"
          context: refapps
      - gradle/test:
          app_src_directory: prototype
          executor: daml-executor
          requires:
            - daml_test

Can anyone help me configure gradle/test correctly?

1

There are 1 best solutions below

3
Gary Verhaegen On

CircleCI has a mechanism to share artifacts between jobs called "workspace" (well, they have multiple ones, but workspace is what you want here).

Concretely, you would add this at the end of your daml_test job definition, as an additional step:

      - persist_to_workspace:
         root: /path/to/folder
         paths:
         - "*"

and that would add all the files from /path/to/folder to the workspace. On the other side, you can "mount" the workspace in your gradle/test job by adding something like this before the step where you need the files:

      - attach_workspace:
         at: /whatever/mountpoint

I like to use /tmp/workspace for the path on both sides, but that's just personal preference.