TFS 2010 Automated Deployment Process - visual-studio-2010

I am trying to understand the automated deployment process in TFS 2010.
I have a DEV, QA, Stage, and Live environments. Using a basic (or standard branching strategy), when configuring automatic builds/deployments does deploying to DEV get code from the MAIN branch to the DEV Server. Then if I want code to go to QA, do the bits on the DEV Server go to QA Server? Then get bits from QA Server to Stage? And finally from Stage to Live? So once code goes from TFS to DEV it's just a matter of moving source code from each Server to the next?
Or is it typical to grab code from DEV branch (instead of MAIN branch) to go to DEV Server and then move code to each Server as described above?
Just trying to understand the automated deployment process and what is a standard configuration.
Thanks for any info given...

TFS does not have a single built-in automated deployment process. You need to specify how and where your code will be deployed, depending on the type of project.
Deployment is about deploying the results of a successful build. Deployment is about branches only to the extent that you have built a branch.

The goal of deployment is to send a branch's code to an environment.
So, if you are working in the MAIN branch and choose to deploy to DEV, the code from that MAIN branch would get deployed (copied, installed, et al) to whatever is configured as the DEV environment.
Most people do not have one branch per environment. You probably would have a DEV branch separate from the MAIN branch, but that's a source control management concern separate from automated deployment. You might want to retag this question along those lines.

Related

TeamCity best practice setup for multiple branches

I'm looking for advice on the best approach to setup TeamCity/Octopus.
Currently I have multiple branches in TFS2015 - dev, main and release (currently we create a release branch for each release).
Our procedure is to develop in dev and deploy to dev environment. When we are ready for testing we merge from dev to main and deploy to test from main. When happy we create a release branch and deploy to live from the release branch. This is a manual process.
Hotfixes are done on the release branch and deployed to live. We then merge back to main/dev.
I'm totally new to this and so far in a VM playground I've setup TFS2015, TeamCity and Octopus and can check-in to TFS, build/create package on TeamCity and deploy this pack from Octopus. But...
I'm unsure how I should setup TeamCity and Octopus to work with multiple branches? Multiple projects for each branch and generate different artifacts?
When I do this for real I have a TFS VM, I plan on installing TeamCity and Octopus on this along with the build agent. Is this a bad idea? Should I create a new VM just for TM and Octopus?
Any advice or best practice would be appreciated.
Although your question is good in scope, but a good answer must cover many details to be complete.
Let me try to point out the main areas that you will need to further investigate and configure.
TeamCity
A VCS root can be configured to listen to multiple branches via a branch specification
A VCS root can contain multiple projects/solutions and these can be built in multiple steps within TeamCity.
Given that Team City does not support conditional build steps, you will need a different strategy to allow you to vary build steps (and parameters) per release channels / environments.
My recommend approach is to split up the builds into a build definition per release channel (target environment).
Dev and Feature branches could share a single build definition.
Master and Hotfix branches can share a single build definition since they both publish to staging/production environments.
Release branches will need a separate build definition and publish to QA/Testing environment.
This gives you fine grained control over parameter and configurations of each release channel. build a debug version of your app from Dev branch for example at major version 3, while build a release version from Master branch with major version 2.
Every build definition will have a step to publish its artefacts/packages to Octopus Deploy, and specify the channel of which the artifacts belong to.
Octopus Deploy
In Octopus Deploy, define the channels to reflect the release channels, that also reflect your branching model.
Develop, Test, Release are my standard goto channels
Each channel can enforce a different Lifecycle to limit the environments that a channel can deploy to and how an application progresses through your overall ALM cycle.
I know this is not a complete answer. but it is a good start that I hope can help you refine your question to more specific technical details.
We're having somewhat similar CI setup requirements except TFS. In our case workflow for most projects is: GitHub -> TeamCity -> Octopus Deploy.
So I'm not sure about multi-branch setup with TFS, but in case with GitHub repos it's pretty easy to configure in TeamCity. You just have to specify branch-related settings in your VCS root (see Branch configuration). When you have configured that, TeamCity will let you run build's for every specified branch separately and will display build statuses for every branch nicely.
In Octopus we use Channels feature to split workflows of releases coming from different branches. That means we have channel-per-branch convention for the projects, so that TeamCity is pushing packaged releases from particular branch (in our case it's develop and master) into it's respective channel in Octopus (see Channels in Octopus).
Probably you can setup all the services on single machine but imho it's not the best practice to do performance-wise and scalability-wise.
Off course I don't know you code etc but I think you should step away from merging from dev to test and then creating a version from test. That way you essentially are building a different application compared to the one you were having on dev. Once you merge from test to production and build your application from there, you are releasing a build you haven't been testing.
You should strive for a flow in which you build once and deploy multiple times. So, build one package which you promote from dev to test to production.
Off course you can have a production branch on which you could fix bugs etc. The Channels feature in Octopus works great for scenario's like that.
So answering my own question (sorry), the approach I ended up taking was to simplify my branches and configure TeamCity/Octopus like so...
Branching Strategy
I've moved from
--dev
--main
--release
----release1
----release2
to
--master
--release
----release1
----release2
Master is where most of the devs do their work, when we are ready for a release we have a cut-off point and merge master into a new release branch.
The release branch is deployed to test and any fixes from testing are made on the release branch.
When testing is complete we deploy to live/production from this branch.
This means that the binaries we have tested are exactly the same as the ones we deploy to live/production.
Teamcity
In TeamCity master is automatically built each time a check-in occurs. Then the package is pushed to Octopus. Octopus acts as a repository in this case. TeamCity also creates the release on Octopus. So it should be checkin->build->create release->deploy.
To do this, I have one VCS Root and have a build configuration called Build-Master. This uses the checkout rules to ensure I'm only using the master branch. I use the Ocotpus packaging to build the package then use the OctopusDeploy runner in TeamCity to create a release automatically and deploy to the dev servers.
Release is different. I want to deploy to the test servers manually rather than each time a check-in occurs. When happy promote this to the live production servers.
Any fixes from test will be made to the release branch and deployed to test.
When testing is complete we promote to live and any hotfixes are made on the release branch. Obviously all fixes/hotfixes are merged down to master.
So, in TeamCity to achieve this I have a build configuration called Build-Release. Again, I use the checkout rules to ensure I'm dealing with the correct release branch.
The build creates a package using OctoPack, however this time it's not pushed to Octopus.
Octopus
Octopus has a project specifically for deploying master to our dev servers, for example projectnamehere-dev.
In Octopus, I have a separate project for Test/Prod. I've setup an external feed which points at TeamCity so I can pickup the package created in TeamCity. This is setup in Library->External Feeds.
So, to deploy to test. I create the release branch in TFS and give it a version number, 1,2,3 etc. I then change the Build-Release build config to point at this new branch. Change the version number.
Then in Octopus, I create a release, select this package and deploy to test. Any fixes from testing are made on this release branch. I just build the package again and create a new release and choose the new package.
When testing is complete, in Octopus I just promote the last release to the live production servers.
Channels in Octopus are used on the two projects because they have different life cycles. I also created two new life cycles, the default is dev/test/prod. I created just a dev and then test/prod.
Hope this helps.
In the version control settings -> vcs -> Branch Specifications: "*" ("This will do all branch, filter as needs be" e.g. +:refs/heads/master +:refs/heads/develop)
enter image description here
Octopus doesn't handle branches, it only deploys, you can however use their rest api, so for example, if test pass in develop then call the octopus rest api to create a new release and deploy.

Netezza CI/CD tool

Is there any CI/CD tool for Netezza that can manage versions and can be used for migrating code across environments? We have used flywaydb for other databases and are happy with it, but that does not support Netezza. I have already googled and did not find a single tool, so any responses are good for me to begin analyzing further
To my knowledge, there's nothing specifically geared for Netezza. That said, with a bit of understanding of your target environment, it's certainly possible.
We use git and GitHub Enterprise (GHE). The reason for GHE is not particular to this solution, but rather because I work at a hospital. Here's what we do.
Setup
Build a repository at /home/nz on your production server. Depending on how you work nzlogs, nzbads, and other temporary files, you may need to fiddle quite a bit with the .gitignore file. We have dedicated log directories where temporary files should reside.
Push that repo into GHE.
If you have a development server, clone the repo in the /home/nz directory on that server. Clearly you'll lose all development work up until that point and will want to make sure that things like .bashrc are not versioned. Alternatively, you could set up a different branch and repo and try merging the prod and dev versions. We did this, but I'd recommend just wiping your development box with production code one slow day.
Assign your production box a dedicated branch in git. For this discussion, I'll call them prod and dev. Do the same for development, if you have it. This is mainly a mental thing, not a tech thing, but it's crucial, like setting up a remote for Heroku or Azure.
Find or develop a tiny web server that can listen for GitHub webhooks. I built a Sinatra server with a simple configuration file. Anything will do. Deploy the web server to each of the environments and tune them to perform the following activities on an update to the prod or dev branches, respective to the server.
git reset --hard
git clean -f
git pull
Set up webhooks in your GHE repository to send the push event to the web servers.
Of course, you can always have the web server do other things on a branch update if you want to get fancy (maybe update cron from a versioned file or update schemas from all new files).
Process
Fairly simply, follow the GitHub Flow workflow. You can pretty much follow whatever process you want with the understanding that your prod and dev branches should be protected and only removed or futzed with as an admin task. Create a feature branch, test it by pushing to dev, and then make a pull request for the prod branch.
Why GHE? Mainly because it keeps an open area where our code is available. You could absolutely do this by pushing directly to Netezza's git repo, but your workflow will suffer--it just isn't as clean as having all code in one clear place with discussion around pull requests.

How do I manage inter-branch dependencies in Perforce?

We are using Perforce and Maven and we are in a situation where we have one branch A that hosts a mature project and another branch B, that we are starting to dev on that uses the code hosted in the first branch.
I anticipate that going forward, there could be cases where a check-in into Branch A will result in failed compilation in Branch B because the developers working on them are not aware of specific usages and cross-dependencies. And then devs will waste time updating B code and figure that its not compiling.
Branch/project A needs to remain as its own separate entity because it's code could be used in another future project.
Can someone advice me around handling and alleviating such problem? Any best-practices that you guys can suggest? Much appreciated.
You need to set up a build environment:
1) Set up a continuous integration (CI) server, such as Jenkins. When a developer commits to Branch A, it should detect the commit and trigger a build.
2) When Branch A completes its build, it deploys its artifacts to a shared repository. Highly recommended (buy not strictly necessary) is that the build for Branch A deploys to a Repository Server, such as Nexus (but a repository in source control or a FTP server does the job too).
3) Set up Branch B in your CI server, but with a build "trigger" that runs whenever a build for Branch A succeeds.
4) Configure both build configurations to email relevant team members (or everybody?) whenever a build fails.
Also, both branches should depend on your repository from #2 above. If you need the entire environment to be repeatable and self-contained, go the repository-in-scm route.

Building ONLY Labelled Versions with CruiseControl.net or TeamCity

We're currently using CruiseControl.NET as a continuous integration server for a number of ASP.NET web projects, but we're also evaluating TeamCity.
This is working great for our build server.
What we'd like to setup is a customer facing test server. I'm thinking that when we are happy for our latest development version to be released to the client for test, we could label it in SVN.
I'd then like a second build server to build this version ready for the client to see.
The question is this - is there any way to get either CruiseControl.NET or TeamCity to build only the latest labelled version of the code in a repository?
If anyone has any alternative suggestions, that'd also be greatly appreciated!
You could have a designated location or branch in your subversion repository e.g. \release then point the second TeamCity build server at that.
When your are happy with trunk then overwrite the existing location. The second build server will pick this up, build it, and even deploy it to a test server.
I don't think there's a way to do this directly in TeamCity. You can however configure your build trigger to filter on files and/or users. So, if you touch a given file to indicate release status in addition to or rather than labelling, you can use that.
The trigger filter could be, for example (untested):
+:/ReleaseVersion.cs

TeamCity and PHP

We are considering TeamCity for continuous integration but have projects in both Rails (Rake tests) and PHP (PHPUnit tests).
I'm a bit new to CI - Has anyone setup TeamCity for PHP projects? If so, is it straight-forward?
Thanks,
Chad
To get the question answered:
Just use ant build scripts, and it'll work with TeamCity.
In the high demand market of web development, using CI is very beneficial and almost a requirement (now a days).
We use TeamCity, YouTrack, Perforce and PHP Maven to build, package and deploy our web applications. The setup is as follows:
Once developed, code is commited to the Perforce repository main folder for the app
TeamCity is configured to check this folder for changes and build each time changes are found (see configuring TeamCity)
Once development has reached a point where it's ready to be deployed, we integrate the main branch with the release branch
TeamCity is configured to check the release branch for changes and deploy via FTP to the server
Cron jobs are running on the app to deploy new releases to a QA branch
Once changes and functionality is verified, the status of the QA deployment is set to "deploy"
Another Cron job is running looking for new QA releases that are ready to be deployed. Once found, it extracts the package into the live folder
In this case, our PROD and QA folders are on the same server. Alternatively, you can have multiple TeamCity build configurations that push the app to different servers (or use a teamcity to define the environment variable).
Also, when we close tickets/issues in YouTrack, we can pull the build info from TeamCity as they interact with each other.
Links:
Configuring TeamCity, Maven for PHP for Joomla continuous build:
http://www.waltercedric.com/joomla-mainmenu-247/continuous-build/1552-configuring-teamcity-maven-for-php-for-joomla-continuous-build.html
We are using TeamCity to deploy a number of PHP sites -- static, Wordpress and Drupal shortly.
We use the Deployer plugin to sftp files to the appropriate server and then a script to rsync the files to the right place and to setup apache. Works very, very well.
Here is a fresh article from JetBrains on how to setup TeamCity with PHP:
http://blog.jetbrains.com/webide/2013/01/continuous-integration-for-php-using-teamcity/

Resources