How to manage CI\CD process for many git repositories (400+), when each of repository needs to be published as NuGet package? Combining Cake and Jenkins features allow building the generic pipeline for packages creation, versioning and publish. Based on C# code, source controlled and compiled in runtime, Cake gives perfect flexibility to build advanced CI\CD process. Large scale also required some tricks inside CI infrastructure and related services.
9. … ok, actually 400+ repos
and most of them are .NET solutions
10. The common issues
• Lot of repositories, managed separately
• Repository-specific logic placed in each repository as scrips
• 1++ jobs in Jenkins to process each repository OR none jobs at all
• Common logic (unit test, nuget publish) need to be applied per each
repository
… as result
• 90 % of all DevOps resources are taken to fix existing jobs and adding new
one
• Impossible to make common changes (adding Sonar, notifications) for all
jobs at once
• “Lost” and “phantom” jobs: build_xxx_repo_dev_temp_1
11. Analyzing existing repositories
Common Unique
C# Solutions count
File structure Scripts (even language)
VS solution Projects type
Git controlled Deploy type
• Manage CICD logic in version control system
• Add ability to minimize Jenkins jobs number by adding
common jobs, which can process multiple repositories
• Allow to easy use CICD scripts outside Jenkins
• Allow to make centralized changes in whole CICD process
as simply as possible.
• Add support for create Nuget Packages
12. The main idea – Repository as Interface
Each repository should contain some
part of internal scripts, which will
have common interface to interact
with repository in same way.
Common Interface members
• REPO HELP
• REPO BUILD
• REPO UNITTEST
• REPO PACKAGE
REPOSITORY
help
build
test
pack
17. Why we are using cake ?
• Cake is not Powershell
• Many build-in integrations
• Cake is C# and Roslyn
• Cake can use PowerShell
• Cake can use tools and add-ins as NuGet packages
• Cake can reference another *.cake as Tasks
• Simpsons already did it
29. Some issues on this stage
• Lot of cake tasks are duplicated
• Hard to make changes in cake tasks
• Adding new repo by copy-paste
• Bug fixes in cake requires changes of all repos
31. Master Repository allows
• Keep all logic in one place
• Fix bugs and implement features quickly
• Avoid code duplication
• Decrease cake script size committed in each repo
• Easy to add a new repository
34. Dependency based programming
package
init clean set new version build pack publish
Task("package")
.IsDependentOn("init")
.IsDependentOn("clean")
.IsDependentOn("setnewversion")
.IsDependentOn("build")
.IsDependentOn("pack")
.IsDependentOn("publish")
.Does(() => { });
35. Dependency based programming
package
init clean set new version build pack publish
before build msbuild unit testsonar begin sonar end
clean nuget restore nunit ncover
36. … what about customization?
Master Repo
build.cake
cake
build.ps1
Repository
custom.cake
src
cake
repo.sln
cake.bat
37. Tasks inheritance
base.package
init clean set new version build pack publish
custom.cake
package
build.cake
base.init base.clean base.version base.build base.pack base.publish
58. Elastic for great CI telemetry
In high scale CI process single build makes no lot of sense, but Jenkins telemetry
allows to show the whole picture.
61. Custom Dashboard
… allows to aggregate events from all system parts and visualize status snapshot,
actual on the current moment of time.
It provide only the required information from large amount of data.