2

I have introduced branching/merging to my team and have talked before about how it would be great to automatically build and deploy code checked into the staging/master branches, but I'm a junior dev, not very ops-y.

The trouble I'm having, is that we create intranet applications and store them on our own VM's which we have access to, but we also have load balancing which is causing me grief!

I can get a build to automate (well, I haven't got all the bugs figured out but I'm working my way through them) - and I can even get the build to automatically create a zip file ready for deployment. Is it possible to configure several servers for deployment? I.E

1) I check in some code to stage
***Automatically***
2) Code builds
3) Build completes, Unit tests run and they complete
4) Code is packaged into a .zip
5) .Zip is deployed across the three load balancing servers (all with the same file path).
***

Maybe worth noting we currently have our TFS server running Visual Studio so the code is built on the same server it is all stored, but this is not the server we run live code from.

Any help or tutorials specific to my setup would be GREATLY appreciated, I really want to turn this departments releasing strategies around!

aspirant_sensei
  • 1,568
  • 1
  • 16
  • 36

1 Answers1

3

I am going to address only the deployment aspect. There are a lot of different ways that this can be handled, such as:

  1. Customizing the build template
  2. Writing custom .Net code and inserting it into the build template (which would also involve customizing the template)
  3. Creating a Batch or Powershell script set to run after the build completes
  4. Using a separate tool such as OctoDeploy or Release Manager to handle the deployments

The first thing you need to do is separate the build and deployment steps in your head. While they are tightly coupled in your model, they are two totally different tasks that need to be handled different ways.
The second thing is to stop thinking like a developer when it comes to the deployment portion. While there will likely be a programmatic solution, you'll need to identify the manual steps first.
You stated that you're not very ops-y, by which I assume you mean you're more Developer and not Systems Analyst. If that is the case, then the third thing you'll need to do is get someone who is involved, such as your current release team.

There are 3 major things that need to be done then:

  1. EVERYTHING needs to be standardized. If you can't standardize something, then standardize the way that it's non-standard (example: You have a bulk list of servers you need to deploy to, and you need to figure out which ones to deploy to based on their name, which can be anything. In that case, a rule needs to be put in place that all QA servers need to have QA in their name, User Acceptance servers need UAT, Production need PROD, etc.).
  2. Figure out how you're going to communicate from the build to the deployment, which builds are going to deployed, to which servers, and where the code is going to be picked up from
  3. You need to document every manual step, and every exception to those steps, and every exception to those exceptions.

Once you have all those pieces in place, you need to then go through each manual step and automate it, whether that's through Batch, Powershell, or a custom-built application. Once you have all the steps automated, you'll have both the build and deploy pieces complete.
After you're able to execute a single "manual" automatic deployment to a single environment, you're then ready to figure out how you want to run it for multiple environments. This can be as complex as an XML file that is iterated through, to simply calling the same command multiple times with different parameters.

A quick summary of how I've done this at my current job (where using a third-party deployment tool was not an option):

  1. Created a tool using .Net WinForms to allow us to "manually" run automated builds (We use the interface to determine the input parameters, and the custom classes under the hood do all the heavy lifting. These custom classes are in a separate project that builds to their own dll. This also allows us to test tweaks and changes to the process in a testing environment before we roll it out to our production build server)
  2. Set up an XML file for each set of environment (QA, UAT, Prod, etc.) that contains all of the servers that need to be deployed to in that environment, including destination paths, scheduled tasks, and Windows Services
  3. Customize the TFS build template and include the custom classes created for the custom tool, which will read the XML file and iterate through each server entry to perform the deployments

I'm more than happy to help with more specific examples and assistance, I look at things a bit different than most people and it helps when it comes to release management.

Taegost
  • 1,208
  • 1
  • 17
  • 26
  • Thanks for all of that - it's a shame TFS isn't capable of just having a really simple 'here's some direct file paths to deploy to' but I guess its not built for intranet so much. We currently have 4 main business units, all with their own QA/UAT/Production (The main BU has 3 Productions for load balancing). If I can get TFS to automate the build, (i.e. dev merges up to QA) - is there no 'automatic' / 'one-click' method to easily release those changes to all QA servers? Actually thinking about it, allowing control over which servers in the 'one-click' method would probably be preferable... – aspirant_sensei Oct 06 '15 at 08:31
  • I believe newer versions (2013+) have better deployment management (I'm most familiar with 2010). Since all environments are different, it's hard to have something that simple out of the box. There are 3rd party tools (Well, Release Management is 1st party now) that can be used to extend the TFS functionality to make deployments much easier, without them it's a tadtricky and requires either custom code or scripts. You could look into ClickOnce publishing, that might be able to do what you need but it comes with its own funky restrictions, and I've never attempted it with an actual build. – Taegost Oct 06 '15 at 19:35