Incremental build in Onerepo (Monorepo) on PR

Answered

Currently we have Onerepo with 200+ .NET solutions – when there is PR we are doing build of all of the – which is madness.

In new repo we want to do it better (yes it will be still one repo because we don’t want 200+ repos). Idea is to run only those builds where PR have changed files. My initial approach was to create build definition in TC for each solution (for now only couple of them for tests) and in each definition I have used checkout rules so build is only watching for changes in this directory. Additionally each build have build feature for pull request so it is watching pr branches. Second step was to create build definition for PR that have trigger on whole repo and snapshot dependencies for all individual solutions. This almost works because on initial build all solutions are build – only after some changes team city is executing only changes solutions.

Is there any way to make this more “intelligent” and fire only solution that have to be checked or use some logic in DSL to choose only builds I want to execute? I already have some powershell script that is fetching bitbucket for diff and know what solutions should be build. Only thing is how to trigger right builds. Of course I can do it manually in Powershell but I would like to use more TC capabilities and reporting,

0
5 comments

Hi Dominik. Sorry, I am not sure I fully understand your question. If you configure the Checkout Rules, you can trigger your build only when there are pending changes that modify files matched by checkout rules. The commits/PRs that do not modify the matching files will not be shown as pending changes. Is that what you was looking for when asked about a more intelligent way to fire the builds?

0

If I remember right it was looking like that. I have two solutions A and B inside folders with same name, I created build definitions basing on PR branches with checkout rules for each and main PR build definition that has snapshot dependency for both. After I made change in one folder and create PR both builds are starting. When I changed something and push once again to same PR then only one build was executed. So this works but not on first time.

0

Thanks for having waited. Say you've changed the solution A. When the dependent configuration (main PR build) triggers, a build in configuration A will be triggered (because the file matching the checkout rules is changed in the pull request). But the main configuration build will see that there isn't a build in the pull request branch on the configuration B and will run one. Further changes in solution A in the pull request branch would not trigger a build on configuration B because it would already have a suitable one.

0

ok you just repeat what I wrote :) The question is following - Can I do it in such way to not run B. In this example it is simple but when having 100 projects when doing change in one file I would like to run one build and not touch 99 others. Maybe it could be done with help of DSL?

0

What you want to achieve is what happens when the main PR build doesn't depend on all other PR builds that have checkout rules. But since the main PR build is triggered and it has dependencies on all other PR builds, the other PR builds need to have at least one build in the PR branch. Would you expect the main PR build to take the dependent builds from some other branch?

0

Please sign in to leave a comment.