Continuous Deployment from Jenkins to a NuGet Feed

Georg Dangl by Georg Dangl in Continuous Integration Friday, September 01, 2017

Friday, September 01, 2017

Continuous Deployment from Jenkins to a NuGet Feed
Posted in DotNet Jenkins

Code sharing via separate assemblies is an ideal way of separating concerns and benefiting from code reuse. For this, it's great to have continuous deployment of development builds when you're iterating fast and only creating manual releases when deemed necessary.

Personally, I'm hosting my private projects on a ProGet instance and the public ones are either on NuGet, or for dev releases on MyGet. Configuring your project is easy:

Instead of using the Version attribute, you're setting the VersionPrefix to the next higher one since your last release. Additionally, a conditional VersionSuffix is appended if the current branch is origin/dev (or whatever development branch you're using). This means your package version will be something like 1.4.1-build-19 in development and when you finally merge to master, it's 1.4.1. Both BUILD_NUMBER and GIT_BRANCH are environment variables provided by Jenkins.

Having a project like this requires then a bit of configuration in Jenkins to deploy to your package feed, MyGet in this example:

I'm using the Credentials Plugin to inject my MyGet API key into the build. The project is configured to auto-package when built in the Release configuration. Then, the package is searched and publish via the NuGet command line utility to my feed. Now on every build, I get a new package pushed to my feed that's available for consumption downstream right away.

When you push to master and want to make your package available directly via NuGet, just download the package from MyGet and release on NuGet. It's not getting any easier!

Happy deploying!


Share this post


comments powered by Disqus

Dangl.Blog();
// Just 💗 Coding

Social Links