Drone in drone using "drone exec"

Hello,

We’re exploring the idea of using drone inside of drone for our monorepo, to have the ability to define a .drone.yml file at the root of each service.

To do so, the main .drone.yml at the root of the repo will download the drone-cli and will run drone exec ./path/to/service/.drone.yml.

Such as:

workspace:
  base: /go
  path: src/github.com/org/repo

pipeline:
  test:
    image: docker
    commands:
      - docker ps
      - apk --update add curl
      - curl -L https://github.com/drone/drone-cli/releases/download/v1.0.7/drone_linux_amd64.tar.gz | tar zx && install -t /usr/local/bin drone
      - /usr/local/bin/drone --version
      - /usr/local/bin/drone exec ./path/to/service/.drone.yml
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

And the service .drone.yml could look like:

workspace:
  base: /go
  path: src/github.com/org/repo/path/to/service

pipeline:
  test:
    image: golang
    commands:
      - go test ./...

Unfortunately this is not working, and after multiple attempts with different flags (--trusted, --privileged, --volume) setting/unsetting docker.sock volume from all .drone.yml, we keep getting the following error:

> drone version 1.0.7
> Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /go/src/github.com/org/repo

This error comes after the drone version got displayed, meaning the drone install is correct and the error is raised by the drone exec command.

Any idea what we might be missing? Any concern regarding this idea of drone inside of drone? Is it actually possible? I couldn’t find any drone plugins with this particular behavior, the closer being https://github.com/drone-plugins/drone-downstream I suppose, but that’s actually not the same thing

drone: 0.8
drone-cli: 1.0.7

I cannot recommend this approach. This has largely been solved in Drone 1.0, which supports multiple pipelines per project and includes support for jsonnet, which gives you the option to store configurations in subdirectories.

Thanks for your answer

Upgrading to drone 1.x is not really an option for us right now, and we just wanted a quick solution to have CI configuration per service.

In the end we were able to make the drone exec command work but only by using the --clone flag. Though we do not want to clone the repo for each sub .drone.yml file, so we still mounted the volume using the --volume flag and overwrote the clone step in the sub .drone.yml so it does nothing.
This is not ideal but it works, and I suspect it’s working because enabling the clone step allows to bypass this part https://github.com/drone/drone-cli/blob/master/drone/exec/exec.go#L266-L270 which was probably conflicting with our own mount attempt.

I took a look at jsonnet as you mentioned for when we’ll take the time to upgrade drone, but tbh I found the doc was a bit light and it was hard to wrap my head around this topic. Are there some tutos/examples incoming?