Automating merge and publish from development to production. Continuous integration - azure

Let's say we have 2 branches: Development and Production
Also we have 2 servers on Azure in different affinity groups.
Is there a way to automate the process so that on person choosing version X that was 'accepted' in development merges code into production branch and publishes to production server ?
Ideally I would want to have a Changset# and set to production that will merge the production branch (with all the required previous changesets) and get published to server.
The chosen changeset does not have to be the latest on development.

Following 4 steps should do it for you:
1) Create a new build definition for Development branch using TfvcTemplate.12.xaml (only available in TFS 2013) as it has post-build script option (see image below).
2) Create a powershell script to merge the changes to branch using tf merge command. You will have to pass the changeset # to the script using Post-build script arguments.
See this URL: http://msdn.microsoft.com/en-us/library/bd6dxhfy
3) When you run the build set the Get Version(see image below) and it will take the changes from that version. After the build is successful it will merge the changes to the production branch using the step 2 above.
4) Create another build for the Production branch and use the link specified in the below answer to deploy the code to azure on check-in to the branch.
Can I automatically update a live site after each commit using TFVC and Azure?
You can also look at InRelease (link below) for Release Management and automation (not supported for Visual Studio Team Services yet)
http://www.visualstudio.com/en-us/explore/release-management-vs.aspx
Hope it helps.

Related

Looking at modifying a pipeline build

I am working for a company that develops a lot of apps and we use Azure devops portal for all of our pipeline releases etc.
So, the general flow is that a developer will create a branch to do the development on and change the code on that branch. They would like to deploy that branch before it is merged back into the development line from a pipeline, rather than from visual studio, which they currently do. So, it's about giving the developer to the option to choose which branch to deploy from.
Has anyone done something similar or point me in the right direction to how I could go about this?
When creating the release, currently there is no build-in feature to choose which branch to deploy from, the release pipeline works with the corresponding source Artifacts configuration.
A good approach for your scenario is referring to the build id on your build pipeline (instead of release pipeline).
When running the build pipeline, you could choose the target branch and record the build id for this run.
In your release pipeline, you could check whether the source Artifacts is from your target branch by checking the build id.

Azure Pipelines best practices for multiple services and environments

I was hoping to get some feedback on using Azure Pipelines and what the best practices are for my situation.
We have recently migrated from TFS 2017 and we are in the process of re-writing all our pipelines. We were using builds and releases prior to the upgrade in the legacy build tasks. We would like to setup more useful YAML pipelines.
Let me set the stage with what we currently have
10+ microservices
10 individual builds that trigger from a folder in the repo for each one
10 releases that get created on successful build
3 environments per release (Dev, QA, UAT)
So in summary... a build of a single microservice triggers off of a commit to a folder in the branch. The successful build then triggers a release to Dev. Dev completes and a user go go start a QA build by clicking the release.
In the new Azure Pipeline world... what would be the best approach to doing this model.
We would like to have all the builds happen in a single pipeline (each stage would be a microservice?)
How do we trigger only on a commit to that folder?
What would the CD look like? Should it be in the same pipeline and be a new stage?
How can we easily just add environments without having to just keep copy/pasting all the code for each environment? Ideally i would like to just be able to add a variable and a new environment can be deployed to
I am open to any suggestions here. I am ok if I am way off here, I am looking for the best practices and best approach to this.
TIA

Source code migration from TFS 2013 to Azure Devops service

Please suggest if someone has experience of migrating source code of 3-4 applications (including their dev, stage & production environment) from TFS to Azure Devops into Git repository & then build the CI/CD pipeline. We don't require work items or history to be migrated.
Can someone give high level steps & what would be approach for migration?
On premise TFS service is TFS 2013 & source code is to be migrated to Azure Devops services. Currently they are using TFVC. Also these are .net applications. One of the application is having around 9.5 GB of data to be migrated. Kindly advice the process and tools which could help with code migration.
Since you are working on TFVC, you need to use a third-party tool GIT-TFS.
The Git-TFS tool is a two-way bridge between Team Foundation Version Control and Git, and can be used to perform a migration. Git-TFS is appropriate if you want to attempt a migration with full history, more than the 180 days that the Import tool supports, or if you want to attempt a migration that includes multiple branches and merge relationships.
You simply need to go through the following five steps to migrate your TFCV repo to Git.
Step 1: Install git-tfs. There are multiple tools to migrate from
TFVC to Git. ...
Step 2: Export to local Git Repo. ...
Step 3: Cleanup New Git Repository. ...
Step 4: Create new Git Repo in TFS. ...
Step 5: Initial Commit to Git Repo.
More details please take a look at this blog-- Migrate From TFVC To Git – 5 Simple Steps

How do I release only changes project from multiple project in one .sln?

I have 7 projects in one .sln. I am using azure devops. There is 4 api and 3 web. I have created two different pipeline for api and web. When commit then both pipeline is triggered.
What I want....
I want only changes project will trigger, build and release. If project 1 is changes then only build and release project 1. Others no.
How do I manage this?
Currently for one change all projects are building and releasing.
Firts of all, if you want only the project you change to trigger the pipeline, you have to create one "pipeline->release" for each project.
When I want something like this normally I create a pipeline whith my build template and then change the trigger option:
Go to edit your pipeline:
And then add the path of the project you want to trigger this pipeline.
So with this you will have a diferent artifact for each project and you will be able to have release only the project you push your changes.
I hope this work for you too!
Update your includes path in the pipeline.
paths:
include:
- /Project1FolderName/*
- /Project2FolderName/*

How can I branch my code in TFS, within a build definition

I'm using Visual Studio Online, and looking at CI and automated deploys
My Web Test Project has three branches: DEV,UAT,LIVE
I have a build Definition that builds from the DEV branch and uses msbuild to deploy the Website to my UAT server, this works fine. What I would like to do is after the publish, branch the code from DEV to UAT
any help would be appreciated
You can use PowerShell post test to call "tf merge" to push code from DEV to UAT.
You are doing it the wrong way round. If you are promoting by quality that is a value of the build output and not the code.
A better way would be to not have branch by quality (dev->qa) but to have branch by release (1.0->2.0). Then have a single build on a version that progress through DEV->QA. This is the recommended method of controlling quality and minimises risk. The release management tools that are part of TFS and VSO use this method.
http://nakedalm.com/create-release-management-pipeline-professional-developers/
If you want to increase and control quality you will need to move away from branch by quality. It is not possible to achieve continuous delivery of any form with it.

Resources