Sharing build using docker plugin

Hi

I have the following yml file

steps:
  - label: "build"
    command:
      - "yarn install"
    agents:
      queue: "v1"
    plugins:
      - docker#v3.5.0:
          mount-ssh-agent: true
          image: "cypress/browsers:node10.16.0-chrome77"

  - label: "compile scripts"
    command:
      - "yarn compile-scripts"
    agents:
      queue: "v1"
    plugins:
      - docker#v3.5.0:
          mount-ssh-agent: true
          image: "cypress/browsers:node10.16.0-chrome77"

  ... more steps 

I would like to use a single build step followed other steps such as unit tests, automation tests, etc. We’re using the docker plugin which is mounting the build agent. Is this the correct way to share the build between steps or is there a mount/volume/meta data approach I should be taking?

Hey @unexpectedsalmon,

I see you’ve also sent an email to support@buildkite.com.
I’ve sent you a reply via email – please let me know if it helps or not!

Regards,
Shevaun

Hi,
Each step runs in its own “environment”, isolated from the rest, that kind of limit your options. I’ve had the same issue and depending on the requirements of the pipeline these are the 2 options best worked for me:

  1. Running both commands on the same step. In you case that’d be running yarn install and then yarn compile-scripts on the same step/docker container. It’s clean, and fast. You won’t be able to “see” them in separated steps, but you do can separate the log sections with something like echo "~~~ Yarn install commands before each of them. (Check the docs on how to manage the log output: Managing Log Out)

  2. The second option is to use the Cache plugin to save the installed dependencies and then share/download them again on the following step. useful when many subsequent steps need the dependencies.

Hope this helps :slight_smile:

1 Like