Jenkins CI in MVC.NET Part 4: Continuous Delivery Find out more about how to deliver continuously as one of the main benefits of the Jenkins CI server. Атанас Атанасов Software Development Manager - .NET Даниела Назим HR Manager Димитър Добрев CTO Eлеонора Георгиева VP of Delivery, MentorMate Георги Дормишев System Administration Manager Георги Петков Delivery Manager, MentorMate Ивайло Костадинов Director of Software Development - .NET, MentorMate Жени Кючукова Director of Quality and Process, MentorMate Nick Curran Director of US Development Стефан Цвятков Director of Software Development - Mobile, MentorMate Стефан Цанев VP of Operations, MentorMate Веселин Добрев Facility and Purchasing Manager, MentorMate Annika Hey Atanas Atanasov Björn Stansvik Founder & Chief Executive Officer, MentorMate Daniela Nazim Dimitar Dobrev Craig Knighton Chief Operating Officer, MentorMate Eлеонора Георгиева Global VP, Delivery, MentorMate George Dormishev System Administration Manager Georgi Petkov Delivery Manager Ивайло Костадинов Director, Software Engineering - .NET, MentorMate Jamie Bolseth President, MentorMate Jay Miller President, MentorMate Жени Кючукова Director, Quality Engineering, MentorMate Jessica Anderson VP of Finance and Administration, MentorMate Liz Spolyar Global Director, Continuation Engineering, MentorMate Nick Curran Николай Любчев Global Director, Talent Acquisition, MentorMate Стефан Цвятков Director, Software Engineering - Mobile, MentorMate Стефан Цанев Chief Financial Officer, MentorMate Vesselin Dobrev Силвия Василева Solutions Architect, MentorMate Sylvia Vassileva Software Development Manager Красимир Николов VP of Technology, MentorMate Филип Гайтановски Filip Gajtanovski Красимир Николов VP of Technology, MentorMate Katherine Kelly Director of Operations (USA), MentorMate Ryan Peña Social Media & Events Manager Carrie Siewert Brady Swanson Global Director, Marketing, MentorMate Eve Poeschl MentorMate Alumni Ryan Peña Васил Василев Vassil Vassilev Павел Петров Director, Software Engineering - LAMP&FE, MentorMate Иван Пеев Senior Technology Manager Ivan Peev Bob Reuss MentorMate Alumni Грета Ямачева QA Manager Вера Петкова QA Manager, MentorMate Greta Yamacheva Robert Samuelsson General Manager, MentorMate Robert Samuelsson General Manager (Sweden) Kyle Simmons Solutions Architect Robin Thomas Solutions Architect Наталия Найденова Solutions Architect, MentorMate Kyle Simmons Robin Thomas Nataliya Naydenova Adam Malone Alex Krasny Александър Димитров Enterprise Architect, MentorMate Andrea Kates CEO, LaunchPad Central Андрей Маринов Software Development Lead - iOS, MentorMate Anurag Shukla Aron Wolde Ashley Goodridge Benjamin Gramlich Chris Black Colin Lee Добринка Табакова Software Development Lead - iOS, MentorMate Doug Leatherman Emily Genco Gavin Finden Graham Klang Хюсеин Хюсеинов QA Architect, MentorMate James Williams John Byrne Лазар Петракиев Любомир Добрев Senior .NET Developer, MentorMate Lyubomir Velkov Mark Smith Roger Ferguson Ryan Fortune Ryan Blake Sarah Rockholt Stefanie Trimble Stephen Fluin Tom Clemens Director of Marketing, MentorMate Adam Malone Alexander Dimitrov Enterprise Architect Andrea Kates , LaunchPad Central Andrew Eklund Andrew Marinov Angel Nikolov Anurag Shukla Aron Wolde MentorMate Alumni Ashley Goodridge Benjamin Gramlich Chris Black Christa Haeg MentorMate Alumni Colin Lee Ian Good Global VP, Operations, MentorMate Deyan Stoynov Dimitar Danailov Dobrinka Tabakova Doug Leatherman Emily Genco MentorMate Alumni Fanka Vassileva Gabriela Zagarova Gary Conkright CEO, physIQ Gary Fingerhut Gavin Finden Georgi Graham Klang Hyusein Hyuseinov Senior Automation QA Iva Jack Cosentino James Williams Krasimir Gatev Senior Android Developer Lazar Petrakiev Lyubomir Dobrev Lubomir Velkov Marin Yotovski Mark Smith MentorMate Alumni Martin Dimitrov Martin Kalyonski Mike Hagan Nikolay Andonov Nikolay Arhangelov Riley Panko Roger Ferguson John Byrne Kaloyan Stoilkov Kosta Hristov Ryan Sysko Ryan Blake Sarah Rockholt MentorMate Alumni Sean McDevitt , Sensei Siyana Slavova Stanislas Walden Stanislav Atanasov Stanislava Bogdanova MentorMate Alumni Stefanie Trimble Stephen Fluin Stoyan Stoyanov Tessa Cacek Tom Clemens MentorMate Alumnus V8 JavaScript Engine Viktor Mitev Yolanda Petkova Pete Anderson , Target Нели Тодорова Software Development Manager - LAMP, MentorMate Росен Колев Technology Principal, MentorMate Атанас Дюлгеров Project Manager Мартин Димитров Senior .NET Developer Станимир Николов Software Development Lead - iOS, MentorMate Георги Бъчваров Solution Architect, MentorMate Злати Пехливанов Software Architect, MentorMate Ася Манолова Software Developer - LAMP, MentorMate Димитър Михайлов Design Lead, MentorMate Светозар Михайлов UI Designer, MentorMate Диляна Тоцева QA Manager, MentorMate Никола Асланов Senior QA Analyst Васил Нончев Software Development Manager, MentorMate Rosen Kolev Technology Principal Dimitar Mihaylov Nikola Genov MentorMate Alumni Neli Todorova Даря Добрева Senior L&D Advisor, MentorMate Yavor Dimitrov Jake Koelln Sr. Account Manager, MentorMate Shelby Schouweiler Contract Administrator, MentorMate Панайот Тодоров Senior .NET Developer Бистра Маркова Senior Talent Acquisition Specialist Георги Каранедялков Software Development Lead - Android, MentorMate Станислав Станчев Delivery Lead, MentorMate Тунг Лам Нгуен Senior Java Developer Ангел Николов Александър Михайлов Software Development Lead - Front-end Денислав Ганчев Technology Principal, MentorMate Стефан Шопов QA Manager, MentorMate Мирослав Андонов Галина Тритакова Talent Acquisition Lead, MentorMate Димитър Гаджев Константин Русев Senior Software Developer, MentorMate Даниел Парашкевов Software Development Lead - .NET, MentorMate Милен Ламбев Software Development Manager, MentorMate Радослав Глушков Software Development Lead, MentorMate Стефан Стайнов Software Development Manager - .NET, MentorMate Явор Димитров Гюрай Мюмюн Senior Android Developer, MentorMate Борислав Димитров Senior Android Developer, MentorMate Цветан Смърдански Senior .NET Developer Марин Маринов QA Manager, MentorMate Tsvetelina Lazarova MentorMate Alumni Николай Архангелов Software Architect Венета Димитрова Android Developer Dimitar Gadzhev Николай Димитров Software Development Lead - .NET, MentorMate Stanislas Walden Николай Андонов Пламен Стоев Software Development Manager - Front-end, MentorMate Александра Маринова Software Development Lead - .NET, MentorMate Мартин Маляков Software Development Lead - .NET, MentorMate Цветелина Лазарова Experience Designer Димитър Николов Software Development Lead - Java, MentorMate Мила Петрова-Димитрова QA Manager, MentorMate Надежда Йорданова QA Analyst, MentorMate Дениз Хашимов Software Development Lead, MentorMate Венелин Венелинов Software Development Lead - LAMP, MentorMate Jake Nelsen Георги Филипов Software Development Lead - .NET, MentorMate Zlati Pehlivanov Senior Software Engineer II Kate Tolmie Христо Савов Software Development Manager - Java Тихомир Минчев Senior Automation QA, MentorMate Мартин Ангелов Director, Software Engineering - LAMP&FE, MentorMate Dimitar Zhelev Димитър Желев Software Development Lead - .NET, MentorMate Joel Swenson Content Manager Кирил Иванов QA Lead, MentorMate Виктор Христосков Software Development Lead - iOS, MentorMate Violeta Nikolcheva Database Developer Виолета Николчева Database Developer, MentorMate Биляна Къдъкевлиева Senior Automation QA, MentorMate Chris McLeod Antonii Georgiev Антоний Георгиев Alexander Rusev Александър Русев Front-end Developer Matt Erickson Public Relations & Social Media Manager, MentorMate Matt Erickson Brian Buchkosky Global Director, PMO, MentorMate Силвия Петрова Manager Business Analysis, MentorMate David Tran MentorMate Alumni Kristin Krueger Junior Experience Designer, MentorMate Kristin Krueger Даниел Ранков MentorMate Alumni, MentorMate Любомир Бамбов Cloud Engineer Александър Александров Lead Business Analyst, MentorMate Иван Великов System Administration Lead, MentorMate Павел Павлов Cloud & DevOps Lead, MentorMate Звезделин Николов System Administrator, MentorMate Магдалена Червенкова Lead Business Analyst, MentorMate Ясена Пейчева Business Analyst, MentorMate Magdalena Chervenkova Николай Николов QA Lead, MentorMate Denny Royal Chief Design Officer, MentorMate Joe Bodell MentorMate Alumni Joe Bodell Technical Account Strategist, MentorMate Виктория Чучумишева HR Manager, MentorMate Мартин Кочев MentorMate Alumni, MentorMate Юлия Поптодорова Project Coordinator Donada Bichaku Business Analyst Евгени Манов Senior UX/UI Designer, MentorMate Тодор Тодоров Senior Cloud Engineer, MentorMate Христо Стоянов Cloud & DevOps Lead, MentorMate Калина Текелиева Senior Content Marketing Artist, MentorMate Kalina Tekelieva Senior Content Marketing Artist Йосиф Генчев UI Designer, MentorMate Невена Цонева Lead Business Analyst, MentorMate Христо Бахчеванов Senior Business Analyst, MentorMate Daniel Rankov MentorMate Alumni Alexander Alexandrov BA Lead Joel Swenson Editor, MentorMate Живко Дуцов Software Architect, MentorMate Димитър Търкаланов MentorMate Alumni Атанас Лазаров MentorMate Alumni, MentorMate MentorMate Никола Донев SysOps & DevOps Lead, MentorMate Димитър Раев Software Development Lead - LAMP, MentorMate Калина Минева QA Lead, MentorMate Clint Rowles VP, Business Development, MentorMate Nikola Donev SysOps & DevOps Lead Цеко Цолов Senior Software Developer Denislav Lefterov MentorMate Alumnus Dilyana Kodjamanova MentorMate Alumni Денислав Лефтеров MentorMate Alumni Диляна Коджаманова MentorMate Alumni Chris McLeod Senior Solutions Consultant Emma Jorstad Project Manager, Lead Emma Jorstad Project Manager Lead Георги Иванов Technology Principal Quality Engineering, MentorMate Мартин Панайотов Senior iOS Developer, MentorMate Веселина Василева Lead Business Analyst, MentorMate Георги Георгиев Software Development Manager - LAMP, MentorMate Никола Генов MentorMate Alumni, MentorMate Жарко Петровски MentorMate Alumni, MentorMate Jordan Keating Design Director, MentorMate John Blake Senior Account Manager Tyler Compton Nikola Peevski Software Developer — Lamp & Front-End Елвис Бабуров BA Lead, MentorMate Aaron Whitney Director of Client Strategy, MentorMate Екатерина Стаматова QA Lead, MentorMate Велислава Минкова QA Lead, MentorMate Илия Янев QA Architect, MentorMate Йоана Лалова Senior QA Analyst, MentorMate Юмюгюл Кязимова Senior QA Analyst, MentorMate Ива Накова QA Analyst, MentorMate Veliko Ivanov Cloud Architect Никола Пеевски Enterprise Architect, MentorMate Велико Иванов Cloud Architect, MentorMate Suzanne O’Brien Staffing Manager Димитър Великов Software Development Lead - LAMP, MentorMate Светлин Станчев Software Development Lead - Front-end, MentorMate Явор Вълчев Software Development Manager - .NET, MentorMate Todor Todorov MentorMate Alumni Kate Stamatova QA Lead Петко Стоянов Software Development Manager - .NET Веселин Хитров Software Development Lead - LAMP, MentorMate Станислав Михайлов Software Development Manager, MentorMate Петя Иванова Director, Software Engineering - Java, MentorMate Frank Anselmo Global Director, Project Management Мартина Даскалова QA Analyst, MentorMate Gyuner Zeki Solutions Architect Боян Икономов Senior Cloud Engineer, MentorMate Румяна Кушева Manager, Project Management, MentorMate Петър Йовев Senior Project Manager, MentorMate Росен Николов Business Analyst, MentorMate Гюнер Зеки Solutions Architect, MentorMate Галин Станчев QA Analyst, MentorMate Цветан Триов Software Development Lead - .NET, MentorMate Sarah Hoops Brenden Diehl Атанас Иванов Software Development Lead - LAMP, MentorMate Владимир Миндов Software Development Lead - .NET, MentorMate Анна Кривова Software Development Lead - Front-end, MentorMate Ивелина Кавалова Senior Business Analyst, MentorMate Ivelina Kavalova Senior Business Analyst, MentorMate Paul Sanders MentorMate Alumni Росен Ранков Data & Analytics Manager, MentorMate Боян Стоянов Senior Data Engineer, MentorMate Людмил Кирилов Senior Data Engineer, MentorMate Георги Мирков Senior Data Engineer, MentorMate Jim Cikanek Senior Client Strategist Самуил Яновски Software Development Manager - Android, MentorMate Йоана Петрова UX Designer, MentorMate Ирена Янкова UX Designer, MentorMate Красимир Гатев Senior Android Developer, MentorMate Кристина Горялова Talent Acquisition Manager, MentorMate Elena Petrova HR Specialist Jay Matre Senior Business Architect, MentorMate Lilyana Dimitrova MentorMate Alumni Josh Marquart Chief Strategy Officer, MentorMate Mario Gorki Senior Mobile Developer Кристина Горялова Talent Acquisition Manager Марио Горки Senior Mobile Developer, MentorMate Елена Петрова HR Specialist, MentorMate Симеон Жеков Junior Cloud Engineer, MentorMate Simeon Zhekov Cloud Engineer Hristo Stoyanov MentorMate Alumni Ben Wallace Enterprise Architect Sebastian Ortiz-Chamorro VP of Engineering, Latin America Consuelo Merino Director of Operations, Latin America In the last articles on the subject of Jenkins CI integration with .NET project we talked only about builds, tests and analysis. This is great, but the main benefit of CI server is the delivery process. In this article we will review how to deliver continuously. Note that these are just a couple of suggestions and tools you can use to do the job, the actual continuous delivery process is a very big topic and is not the subject of this post. Web Deploy Visual Studio Web Deploy When you wont to deliver to different environment, You need different configuration files for every environment. The reason for this is because different environments or clients build need different connection strings, file servers, etc. Microsoft is providing a web.config transformations. In order to create a transformation file for all environments you need to: Go to ‘Build -> Configuration Manager…’. On your presentation project (Web, Desktop, etc.) create configuration for all your environments like Test, Stage, Production Client 1, etc… Got to your Web.Config and on the context menu select ‘Add Config Transform’. This will add transformation file for all your environments and you can edit it. Now you need to create a publish profile for all your environments. You can do this by going to your project context menu and select ‘Publish…’. Publish to the environment you like. Notes: For more transformation options see the links in references. On your publish servers you need Web Deploy installed, except if you are publish on local network filesystem. Editing the publish profile On some deploys you will need to include extra files like dynamically loaded dlls or other needed files. In order to do this you need to edit all your publish config files (should be located at MY_PROJECT_FOLDER/Properties/PublishProfiles/*.pubxml). The following script add to the publish archive ‘/bin’ folder the dll files that start with ‘App.Lib’ and the ‘AuthorizeNet.dll’. <Target Name="CustomCollectFiles"> <ItemGroup> <_CustomFiles Include="binApp.Lib.*.dll" /> <_CustomFiles Include="binAuthorizeNet.dll" /> <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)"> <DestinationRelativePath>bin%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath> </FilesForPackagingFromProject> </ItemGroup> </Target> <PropertyGroup> <CopyAllFilesToSingleFolderForPackageDependsOn>CustomCollectFiles;</CopyAllFilesToSingleFolderForPackageDependsOn> <CopyAllFilesToSingleFolderForMsdeployDependsOn>CustomCollectFiles;</CopyAllFilesToSingleFolderForMsdeployDependsOn> </PropertyGroup> Jenkins Web Deploy On the Jenkins CI you will want to deploy to the different environments. When you do this you may want to set some extra parameters in the config files, like some application version or logging options. You can do this with an XPath tool like this one. Example of how to use it is: REM 'Change Configs On Pre-Deploy.' "C:ToolsXPath.exe" -file "%WEBPROJECT%Web.config" -xpath //configuration/appSettings/add[@key='AppVersion']/@value -value "1.%BUILD_NUMBER%.%SVN_REVISION%" "C:ToolsXPath.exe" -file "%WEBPROJECT%NLog.config" -xpath //ns:nlog/ns:rules/ns:logger[@writeTo='mail']/@minlevel -value "Error" -ns http://www.nlog-project.org/schemas/NLog.xsd After that we deploy with MSBuild. If you have a publish plan named „DEPLOY.TO.STAGE“, You can deploy it like this: Command Line Arguments /p:DeployOnBuild=true /p:PublishProfile=DEPLOY.TO.STAGE.pubxml /v:q /nologo Third party services Often you will want after a build or deploy to notify a third party application or service. The problem is that there isn’t plugins for all applications out there and some of the plugins do not work for every version of Jenkins. For example that was the issue when I tried to notify https://www.pivotaltracker.com/ on successful job complete. There is existing plugin for integration with pivotal, but for some reason it didn’t work with my version of Jenkins. So how to communicate with such third party apps and services. You have 3 options: Find a plugin that work. There are many plugins in Jenkins and some of them can help you. Just go and try to find one here before doing anything else. Write your own plugins. If you are a fan of Jenkins you can always contribute to the project by writing a plugin that integrates with one service or another. The problems is that I have found it hard to even start developing plugins for Jenkins, because the process is not so easy. And some time you just want a quick and easy solution. A third option is to use the Jenkins CI API. Jenkins provide a option to extract the current build parametars in a xml or json format. You can filter the parameters with xpath, transform it and send it to a third party service. In order to use the API you will need a access token. You can set it in ‘Your Jenkins Profile -> Configure -> API Token’. After that you can access the build properties simply by calling the %BUILD_URL%/api/xml. You can add wrapper and xpath query parameters. Also you have to add basic authentication with your jenkins username and api token. An example of application that take the changes and send them to pivotal can find here. Continuous The idea of continues integration and delivery is that you do it periodically or when given event occurred. In that way you do not do a big and painful integrations and deliveries. The continues integration is when all developers keep their work integrated. You can read more about integration and delivery here. Integration Triggers You can use the ‘Poll SCM’ triggering of integration process. On a given period of time Poll SCM checks the remote repository for changes and start the job if any new pushed are detected. The better ways is to trigger a build on commit. One way to do this is to use post commit hooks that send a POST request to the JENKINS_URL/job/JOBNAME/build?token=TOKEN. Some servers like GitLab have integrated solutions for triggering a build right after push. This post commit builds can integrate future branches into the master branch, do a merge request or just compile the project to make sure the project can be build. There is many configurations that can be made. One possibility is to create a post commit that only build the projects and run the tests. After that a daily build that integrate into master branch and weekly that run the acceptance tests and create a tag that can be deployed to test environment. The setups can be different depending on the project needs. Strategy In the first post of the series we have described how to use a pre-master branch. You have other possibilities with Jenkins. Developers can use future branches and Jenkins can integrate or create a merge request with master. The Git plugin allowing it. Another option is to use a feature toggles. You can include a future framework like this ones (preview some of them here). With the Web.config transformations you can activate different futures for the different environments and clients. Extracting documentation One of the useful things when to finish your integration to the master is to periodically extract a documentation of your code and overall description of your project. This can be deployed to a public site or to though a Jenkins HTML Publish plugin. For the extraction of JavaScript documentation you can use JSDoc (run it with rhino) and for C# documentation Doxigen or XSL transformation to html. Delivery The continuous delivery is a process of continually delivering stable versions to your environments. A different plugins like Violations can set your build as stable and unstable. After stable build we have the opportunity to create tags. In that way stable builds will be ready for deploy to test or stage environment where testers and clients can test and review the application and the new futures. The continuous delivery process can contain many configurations like post-commit, daily, weekly jobs, jobs that deploy to different environments, etc. We can create jobs for every configuration and execute the same commands over and over again, but this will become harder to maintain and harder to comprehend. A better way is to organize all jobs for a given project in delivery pipeline (see references). After setting the delivery pipeline (by triggering jobs one after another) you can visualize the process by pipeline view plugins like Delivery Pipeline Plugin and Build Pipeline Plugin. Sometimes you want to promote a version from test environment to stage environment or above. However it is better to do this, if the QA team is deemed the version stable. So you will need to allow external users of Jenkins to trigger builds manually. This can be done with triggers. Triggers Manual triggering of a job can be done by email. There is some plugins that can perform this like Mail Commander Plugin and Mailbox Trigger Plugin. They can do the job, but do not have validation or authentication if you require it. Another way to allow manual trigger of specific jobs is to write your own tool or script that access the Jenkins CI API for triggering jobs. You can write a small page or do a script and send it to the people that will promote the builds to different environments. Deploy When you want to promote to different environments it is a good idea to preserve the code in artifact and then to transform and deploy it. One possible MSBuild project that you can use is located here. You can use it in your project and modify it for your needs. If you call it with the following command it will copy all files for publish at single location and all Web.config transform files. Command Line Arguments MSBuild.xml /p:PublishTargetsDirectory=%WEB_TARGETS_PATH%; ProjectName=%PROJECT_NAME% The WEB_TARGETS_PATH is the path for your web publish targets. This can possibly be „C:Program Files (x86)MSBuildMicrosoftVisualStudiov12.0“ or other VS version file. The PROJECT_NAME is your project name. The next command on the same MSBuild project file will transform the Web.config with Web.Test.config and create a package file for deploy. Command Line Arguments MSBuild.xml /t:PrepareDeploy /p:PublishTargetsDirectory=%WEB_TARGETS_PATH%; ProjectName=%PROJECT_NAME%; Configuration=Test Now you can use msdeploy to deploy to test environment. Delivery process diagram References Web Deployment: Web.Config Transformation Jenkins Parameterized Builds Git, Feature Branches, and Jenkins – or how I learned to stop worrying about broken builds Continuous Delivery: Anatomy of the Deployment Pipeline Orchestrating Your Delivery Pipelines with Jenkins How to use Jenkins for Job Chaining and Visualizations Тагове Software DevelopmentWeb Сподели Share on Facebook Share on LinkedIn Share on Twitter Сподели Share on Facebook Share on LinkedIn Share on Twitter Запишете се за нашия бюлетин Запишете се за нашия бюлетин