32

The new way to extend VSTS Build and Release

Embed Size (px)

Citation preview

Page 1: The new way to extend VSTS Build and Release
Page 2: The new way to extend VSTS Build and Release

Extend Build and Releaseusing TypeScript or PowerShell

Jesse HouwingLead Consultant Xpirit@jessehouwing

#TECHDAYSNL @VSTEAM

Page 3: The new way to extend VSTS Build and Release

JesseHouwingLead Consultant at Xpirit@[email protected]

Page 4: The new way to extend VSTS Build and Release

• Built a custom MsBuild Task?• Hand-edited a Visual Studio Project File?• Customized a targets file?• Built a XAML activity?

• Created his own Node/Bower/Grunt package?

• Created a build task that’s out on the Market Place?

Who has ever…

Page 5: The new way to extend VSTS Build and Release

A very quick recapBuild agents run tasks

• Tasks run tools

• Tasks run scripts

• Tasks run tools that run scripts

Page 6: The new way to extend VSTS Build and Release
Page 7: The new way to extend VSTS Build and Release

Many tasks onThe Visual Studio Marketplace

Page 8: The new way to extend VSTS Build and Release

What if you do something special?Write a PowerShell or Batch script, commit it to your repo and call it from a build.

Page 9: The new way to extend VSTS Build and Release

You can run your scripts

in-line

Page 10: The new way to extend VSTS Build and Release

When would you create a task?• When the functionality doesn’t ship out of the box• When there is no task available on the marketplace

• To make your script re-usable• To make it easy for others to consume your script• To interact with the agent

• When you want to share your creation to the world

Page 11: The new way to extend VSTS Build and Release

Where to startRead the VSTS Task SDK docsLook at the VSTS Task LibraryPeek at the tasks on the build agentC:\TfsData\Build\_work\_tasks\*

Page 12: The new way to extend VSTS Build and Release

Must have toolboxNodeJShttps://nodejs.org/en/

Typingsnpm install typings -g

TypeScriptnpm install typescript -g

TFS-CLI (tfx)npm install tfx-cli -g

Page 13: The new way to extend VSTS Build and Release

VS

Page 14: The new way to extend VSTS Build and Release

PowerShell or TypeScript or Both?PowerShell TypeScriptSupported on Windows Supported on Windows, Linux and MacCan call into existing PowerShell modules Can call PowerShell.exe for similar functionalityCan call into existing .NET APIs Can call PowerShell.exe for similar functionalityOnly supported on Windows Single implementation for all platformsDynamic typing Static typing with compiler and linterUses TFS Client Object Model to talk to TFS / VSTS REST and SOAP endpoints

Uses TypeScript SDK to task to TFS / VSTS REST endpoints

Yes you can code a task directly in JavaScript, but why would you?!

Page 15: The new way to extend VSTS Build and Release

I’m starting to prefer TypeScript

TypeScript

Page 16: The new way to extend VSTS Build and Release

An Extension manifestExtension ID and Publisher

A Task manifestTask ID and Task Name

Inputs & Execution

Implementation(s)Powershell or TypeScript/Javascript

DependenciesTask SDKTools & other assemblies

Page 17: The new way to extend VSTS Build and Release

Create a task using Typescript

DEMO

Page 18: The new way to extend VSTS Build and Release

Create a task using PowerShell

DEMO

Page 19: The new way to extend VSTS Build and Release

Tips & Tricks

Page 20: The new way to extend VSTS Build and Release

Dependencies

• Embed them in your task / extension

• Fetch them on demand

• Demand their existence through Capabilities and Demands

Page 21: The new way to extend VSTS Build and Release

Capabilities & Demands

DEMO

Page 22: The new way to extend VSTS Build and Release

Tasks run locally now!Making them much easier to test than before!

Page 23: The new way to extend VSTS Build and Release

Testing your tasksArrange• Import the SDK• Set Environment variable

Act• Execute your task

Assert• Inspect the expected results

Out-of-the-box mocks are on their way!

Page 24: The new way to extend VSTS Build and Release

A note on variables

!

Don’t rely on variablesUse inputs instead

Page 25: The new way to extend VSTS Build and Release

Versioning• Always increase your version with every

publish• Always increase both the Extension version

and the Task version• Use a different Extension ID to limit

visibilityDevID: PingTask-DEVVisibility: PrivateShare: Your Dev Account

PreviewID: PingTask-PREVIEWVisibility: Private PreviewShare: Trusted Accounts

PublicID: PingTaskVisibility: Public

Page 26: The new way to extend VSTS Build and Release

And agent versionsVersion Shipped with PowerShell PowerShell

SDKJavascript XPlat

Node SDK

1.83 TFS 2015 RTM Yes Preview1.89 TFS 2015 QU 1 Yes Preview1.95 TFS 2015 QU 2 Yes Yes Preview

1.95.1 TFS 2015 QU 2.1

Yes Yes Yes

1.95.3 TFS 2015 QU 3 Yes Yes Yes

1.105.6 VSTS Yes Yes Yes2.105 TFS 15 RC Back compat Yes Yes2.107 VSTS Back compat Yes Yes

Page 27: The new way to extend VSTS Build and Release

When open-sourcing

• Override Extension ID• Override Publisher• Set your version to 0.0.0• Omit/Set visibility to

private

• This prevents people from accidentally publishing a duplicate extension

! {

"manifestVersion": 1,

"id": "vsts-extension-tasks-

DEV",

"name": "VSTS Extension

Tasks",

"version": "0.0.0",

"publisher": “set-your-own",

“public": “false“

}

Page 28: The new way to extend VSTS Build and Release

Setup a build pipeline for your tasks• Use VSTS to build and publish your tasks• And Remember your PAT for you

Page 29: The new way to extend VSTS Build and Release

Setting up Build & Release in VSTSDEMO

Page 30: The new way to extend VSTS Build and Release

Help improve extensions by submitting your issues and pull requests to GitHub!

Page 31: The new way to extend VSTS Build and Release

Next steps…Publish your own tasks to the marketplace?

Page 32: The new way to extend VSTS Build and Release

THANK YOU!Jesse HouwingLead Consultant Xpirit

[email protected]@jessehouwing

#TECHDAYSNL @VSTEAM

bit.ly/XpiritMagazine

bit.ly/td-minihacks