Authoring Azure DevOps Task — Overview (1)

Tsuyoshi Ushio
4 min readJul 29, 2019

I want to share the resources, samples, and testing strategies on this blog post for someone who wants to author an Azure DevOps task with typescript.

This series of articles will cover these areas.

* Useful documentation link and GitHub projects
* How to create a development environment
* How to create a CI/CD pipeline
* Strategies for Unit Testing

I hope you enjoy these. If you know the better way to do it, please leave comments for share.

These are the series of post of this topic.

Installation

You can follow this Official Documentation. This document is excellent to start.

You will need these tools/libraries.

Terminology

You will develop an extension for your custom task. An extension can have several tasks.

Overview

Project Structure

The primary project structure will be like this.

src
task.ts
task
icon.png
task.json
test
images
extension-icon.png
.gitignore
README.md
package.json
tsconfig.json
vss-extension.json

src

You can put your code in here. I recommend creating this directory to enable you to get code coverage.

task

icon.png is the icon of this task. It will show up on your pipeline. The size should be 32 x 32. task.json is a configuration file of the task. You can create several task directories for each task. When you pack this source, you need to copy source code and node_modules in this directory.

test

Put your test code

images

Optional; however, you can include the icon image for this extension. It will be 128 x 128.

README.md

Readme file. Sometimes you might use it for the market place top page. If you use an image, I recommend not to use relative path. e.g. https://raw.githubusercontent.com/TsuyoshiUshio/CommentPRTask/master/doc/images/Comment.png. This tips useful when you publish your extension.

package.json

The configuration file of npm.

tsconfig.json

Configuration file of typescript.

vss-extension.json

Configuration file for this extension.

task.json

task.json includes name, description, author, icon, and version of the task. The id should be unique in WW. It is a GUID. Also, ‘task.json’ defines the Input on the GUI or YAML input parameters. Also, which source code to execute. It should be a javascript file.

vss-extension.json

vss-extension.json includes name, description, author, icon, and version. It also includes if the extension is public or private. It also includes Service Connection Input parameters and tasks.

Development process

1. Develop your task

Develop and run unit test locally.

2. Upload to your Azure DevOps project and test it

You can upload your task to an Azure DevOps organization with `tfx build tasks upload` command. More details here.

3. Publish to the Market place

Once you verify it works, publish to the Market Place. If you don’t have an account. You need to create it. You can refer the steps of “Step5: Publish your extension” here.

Project pages

azure-pipelines-tasks

You can find an excellent live example of Azure DevOps task. You can read the source code. I recommend reading the Tasks/XcodeV5 task as an example.

Node CLI for Azure DevOps

The repo of `tfx` command. The tfx command enables you to :

  • Generate Template
  • Upload your task to your Azure DevOps organization
  • Package your extension
  • Publish to Market Place

Azure Pipeline Task SDK

Azure Pipeline Task Lib project page.

Conclusion

I wrote about the overview of Task development. I’ll explain how to create a development environment in the following post.

--

--