Our project is nested inside a mono-repository. Imagine this, we have a project in a "projects" folder. For example "projects/our-project". Well, we would like to be able to check our .drone.yml into just "our-project" but it appears Drone wants the configuration file at the root of the project, which is ok, we can work with that by changing the "commands" section of our builds. The trouble we are running into is that we only want to run the builds when something in "our-project" changes. I can't find a way to do that precisely with Drone so our next closest bet is conditions, I figure we can make namespace all branches for "our-project" like this "our-project/some-branch". Then we could set up a condition, to only run builds on "our-project/some-branch" and "master" this would limit the number of "fake builds" we are running from other projects branches:
build:
when:
branch:
- master
- our-project/*
The trouble is when we try to pull request from a "our-project/" branch to "master" the build won't run, I'm guessing because its being run on a merge commit which isn't in master or "our-project/"
My question is two fold: 1. What is the best way to leverage drone using the mono repository pattern (multiple projects, one repository) 2. If Drone doesn't have support for that pattern or isn't designed for it, what is the best work-around to limit "fake builds"
Note: We could at the beginning of our build check for changes in our sub-folder and return a green if there aren't any. I this a recommended approach?
There's multiple solutions for this problem now.
As a start you can use exit (78) code which skips subsequent steps in pipeline but this workaround require you to define multiple pipelines that can be skipped.
Example:
- name: Check_src_for_changes
image: alpine/git
commands:
- if (git diff --exit-code $DRONE_COMMIT_BEFORE $DRONE_COMMIT_AFTER -- src); then exit 78; fi
Also This is currently handled multiple extensions due to the new category of Drone plugin called a configuration plugin:
Anyone can create an extensions using drone starter projects
Extensions can be used to override how Drone fetches a yaml allowing you to create or modify yaml files on the fly. There are multiple extensions that solve this problem today that you can use. Here are a few:
For more about this issue please refer to issue#1021
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With