Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous...

19
Live! 360 Orlando 2015 VST08 Automate Your Builds with Visual Studio Online or Team Foundation Server Tiago Pascoal Automate Your Builds with Visual Studio Online or Team Foundation Server Tiago Pascoal Microsoft Visual Studio ALM MVP Level: Introductory to Intermediate Who Am I [email protected] http://pascoal.net

Transcript of Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous...

Page 1: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Automate Your Builds with Visual Studio Online or Team

Foundation Server Tiago Pascoal

Microsoft Visual Studio ALM MVP

Level: Introductory to Intermediate

Who Am I

[email protected]://pascoal.net

Page 2: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Agenda

• A trip down to memory lane - A bit of history

• Team Build 2015

• Demos Galore

• Q&A

Project Server Microsoft System Center Microsoft Azure SharePoint

Source control

Agile planning

Test case management

Build automation

Continuous deployment

Release management

Load testing

Lab management

Feedback management

Team collaboration

Application telemetry

Big Picture

Page 3: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Quote from the book Show Stopper© G. Pascal Zacharyhttp://www.gpascalzachary.com/showstopper__the_breakneck_race_to_create_windows_nt_and_the_next_generation_at__50101.htm

Automating builds in a Microsoft World in ancient times• Batch files

• Make

• Invoking Visual Studio command line

• Nant (2001)

• Cruise Control.Net (2003)

Page 4: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Microsoft Build• MSBuild is introduced with .Net 2.0

• Visual Studio 2005 adopted MS Build files for it’s project files– This allowed building Visual Studio Projects without the need to

have Visual Studio

– Some exceptions• Biztalk

• Setup projects (vdproj)

• …

But…

• MSBuild was “just” a build engine….

Page 5: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Team Build 2005• Part of TFS 2005

• Team Explorer/Visual Studio included a wizard to create build types– Get & label code from source control

– Compile

– Run tests

– Run code analysis

– ….

– Associate changesets & workitems to build report

– Store the build results

• Build Scripts Customizable

• The build engine?– MSBuild

Team Build 2005common complaints• Used MSBuild files to orchestrate the build

– tfsbuild.proj was the build script

• MSBuild is powerful but not easily customizable

• The script was private to the build type. It was hard to have a common behavior. If you made a change to a build type you had to manually change all instances

Page 6: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Team Build 2010 and 2012,2013

• Templates– Build definitions are instances of templates with

specific parameters

• XAML Build Templates– Windows Workflow Foundation

• Controllers and Agents– One controller can have multiple agents

Team Build 2010common complaints• You need one dedicated machine per TFS collection

– One controller per machine (and one controller per collection)

• No Definition Versioning– Build templates are stored in version control and versioned

– Build definitions are not

• Customizing build templates is not easy– WF Designer cumbersome and slow

– Sometimes you need to manually tweak the XAML file

– You need to be aware of some tricks

• Requires Team Explorer

Page 7: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Team Build 2015 (1/2)• KISS principle: CI == dev

– Use the same build tool(s) used by the developer

– No weed to wrap it on msbuild

• Customizations are simple

• Simple Web UI – Doesn’t need team explorer

• Shows all the logs

• Cross Platform builds – Windows, Un*ix and Mac OS agents

Team Build 2015 (2/2)• Controllers are gone

– Greater scalability

• Build definitions are versioned– You can now audit what has changed

• Agents have ability to automatically update themselves

• More secure– Runs with less privileges (uses scoped OAuth token and executed code can’t grab

credentials)

• Works side by side with XAML builds – Investments in XAML builds are not lost

Page 8: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Team Build 2015Queues, Pools & Agents

Team Project Collection 2

Queues

Team Project Collection 1

Queues

Pools

Agents

Agent Hosting• Visual Studio Online

– You can use the Hosted build agents• Pay per usage with free minutes included

– Host your own build agent• Cloud

• On Premises

• Team Foundation Server– Host your own

Page 9: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

DEMOInstalling an agent

Build Tasks• Building blocks to compose builds

– Tools meant to be run

• Written in – Powershell (windows)

– Javascript (xplat)

• Tasks may demand the agent machine has certain characteristics– Eg: Java is installed

• Available as Open source

• Also work on new Release Management vNext

Page 10: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Build Definition• A sequence of steps; Tools being run sequentially just like a

developer does– Run a task with parameters

• Steps are called sequentially, if one of them fails execution is aborted

– Unless the step is explicitily configured to “Continue on Error”

• Can be allways called even if a build fails– Like a finally block on C#/Java

• You can have Disabled steps– Execution is skipped

DEMOCreating build definition

Page 11: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Variables• Variables are available in build definitions or build scripts• Variables have three scopes

– System Variables – Defined by the host and the agent. • EG: System.TeamFoundationServerUri

– Global Build Variables – defined at the agent level. Tasks and build scripts can also contribute with its own variables

• EG: Build.DefinitionName – Agent Build Variables - defined when the build job is started

• EG: Build.Repository.LocalPath

• Variables are available as environment variables• You can have “secret” variables• There are predefined variables by the system

– http://go.microsoft.com/fwlink/?LinkId=550988

DEMOVariables

Page 12: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Multiconfiguration

• Build multiple configurations with a single build definition

DEMOMulti Configuration

Page 13: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Building code from a repository• Source code ban be built from code stored on:

– Team Foundation Version Control

– “TFS Git”

– Git

– GitHub

How Builds can be startedTypes of triggers• Manual

• Continuous Integration– Can be batched– Build is triggered by a code commit/checkin– extra filters available

• Include/exclude certain paths that trigger build• Branches

• Scheduled– User defined schedules

• Eg: nightly builds– Supports multiple schedules

Page 14: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Templates

• Templates can be used to pre populate your build definitions

• Steps populated– With or without pre filled values

DEMOTemplates and repositories

Page 15: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

How agents are chosen

• When a build is queued, which agent executes it?

• Agents are chosen based on– Build definition required capabilities

– Build definition tasks demands

DEMOEnd to End Build

Page 16: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Other Features• Tags – You can apply tags to builds

• Build Badges – Embed build status on a web page

• Pin to homepage – Pin to a team dashboard build status overview

• Save as Drafts

• Clone

• Git Policies – trigger builds on pull requests

Extending Team Build• You can either create your own taks or use tasks created by other

people

• You can manage tasks using the new cross platform tfx command– npm install –g tfx-cli

• Tasks are implemented in– Powershell for .Net agent– Javascript for cross platform agent– The task can contain an implementation for both agents

Page 17: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

DEMOImplementing a custom task

Ask not what a developer can do for a build but what a build can do for a developer

[poetic paraphrase :-)]

Page 18: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

Conclusions• Team build is an orchestrator

– Use the build tools you are familiar with

• Edit build definitions using web browser

• Cross Platform

• View build report details on the web

• Auto updating agents

• Use powershell/shell scripts or create build tasks

• auditing

• http://pascoal.net/vslive-orlando15

• https://github.com/tspascoal/vslive-orlando15

Additional Information

Page 19: Who Am Iredmondevents.com/virtual/vslive/2015/live360or/pdf/VST08_Automa… · Continuous deployment Release management Load testing Lab management Feedback management Team collaboration

Live! 360 Orlando 2015

VST08 ‐ Automate Your Builds with Visual Studio Online or Team Foundation Server ‐ Tiago Pascoal

THANK YOUQuestions?