How to run build in local machine with drone.io

14.1k views Asked by At

Does the build have to run on the drone.io server? Can I run the build locally? Since developers need to pass the build first before pushing code to github, I am looking for a way to run the build on developer local machine. Below is my .drone.yml file:

pipeline:
  build:
    image: node:latest
    commands:
      - npm install
      - npm test
      - npm run eslint
  integration:
    image: mongo-test
    commands:
      - mvn test

It includes two docker containers. How to run the build against this file in drone? I looked at the drone cli but it doesn't work in my expected way.

1

There are 1 answers

2
Daniel Cerecedo On

@BradRydzewski comment is the right answer.

To run builds locally you use drone exec. You can check the docs.

Extending on his answer, you must execute the command in the root of your local repo, exactly where your .drone.yml file is. If your build relies on secrets, you need to feed these secrets through the command line using the --secret or --secrets-file option.

When running a local build, there is no cloning step. Drone will use your local git workspace and mount it in the step containers. So, if you checkout some other commit/branch/whatever during the execution of the local build, you will mess things up because Drone will see those changes. So don't update you local repo while the build is running.