Pipelines | Status |
---|---|
Extension build and release | |
Extension consumer |
This repository contains modules for the workshop on building azure devops extensions to help collegues get started with azure devops extensions
Table of Contents (click to open)
The workshop assumes that you have access to the following resources:
- Azure DevOps Account
- Node.js
- Linux or WSL on Windows
- GNU Make (Optional) Windows
The workshop assumes that you have basic knowledge on:
- Javascript/Typescript
- Sinon, Mocha, Chai testing
-
Sign in to Azure DevOps using your personal microsoft account.
-
Create an organization. You can provide any name, make sure it's a unique one.
-
Create a project by clicking the
New Project
button.The project will hoist your extension-code and release pipeline.
-
Create a repository in the first project space for your extension code.
-
We'll need to install the necessary Azure DevOps Extension Tasks by Microsoft installed to build and release azure devops extensions.
-
Clone the repository code and delete the current git remote using below steps. (We will upload the same code to the azure repository).
# Git clone the repository git clone https://github.com/Biswajee/Azure-DevOps-Extensions-Workshop.git # Remove the remote url for the cloned repo git remote remove origin # Add the new remote url from your azure devops extension repository git remote add origin https://<OrganizationName>@dev.azure.com/<OrganizationName>/<ProjectName>/_git/<AzureRepositoryName> git push -u origin --all
-
Check whether the code you've pushed got successfully updated in the azure devops respository.
Horray! You've completed the first subtask 🎉🎉
-
Go to the project space where your extension repository is present.
-
[User Settings]
>[Personal access tokens]
>[ + New Token]
.Select All accessible organizations under Organization while setting up the token. Please provide full access to your token for the demo purpose. Generate your token and keep a copy of the same.
-
[Project Settings]
>[Service Connections]
>[Create Service Connection]
. -
In the search bar, find Visual Studio Marketplace. Click Next.
-
Add your personal access token that you copied earlier.
-
Provide the name of the service connection and an optional description.
-
Make sure the Grant access permission to all pipelines is checked ✅.
Please note the name of the service connection after creating.
- Go to the publish your extension page and create a publisher. Please note the publisher ID after creating.
(Any details other than the name of the publisher and the publsher id are optional.)
The Azure DevOps pipeline is located at the root of the project here. Please update the values in the variable section of the pipeline (Line 19 to 29) as under:
variables:
# the publisher id you've created
publisherId: <YOUR-PUBLISHER-ID>
# the value of url after https://dev.azure.com/<YOUR-ORGANIZATION-NAME>
# this value will be used to share the produced extension with the organization
# multiple values can be provided as shown: organization1,organization2
shareWithOrganization: <YOUR-ORGANIZATION-NAME>
# example of organization url: https://dev.azure.com/biswajitr
shareWithOrganization.URLs: <YOUR-ORGANIZATION-URL>
# the name of the marketplace service connection that you've created
marketplaceServiceConnectionName: <YOUR-MARKETPLACE-SERVICE-CONNECTION>
Now, we're ready to create our first pipeline 🎉
-
Click the pipelines icon in the azure devops platform.
-
Click on
[ New Pipeline ]
button. -
Select following responses when prompted:
-
Where is your code: Azure Repos Git
-
Select a repository:
-
Configure your pipeline: Existing Azure Pipelines YAML file
-
Enter pipeline path as:
/az-build-and-release-pipeline.yaml
-
Click on continue to setup your pipeline.
Review your pipeline YAML and hit run to execute the pipeline.
Now that your build and release pipelines executed successfully, we can test our extension using another pipeline. Before, we can do that you must ensure that the extension is shared with the organization where you're trying to use.
The azure devops extension gets automatically installed in the target organization when the build is triggered using the azure pipelines.
You can verify whether the extension is installed properly by visiting -> Organization settings -> Extensions.
or https://dev.azure.com/<OrganizationName>/_settings/extensions?tab=installed
.
Now, we are ready to test our azure devops extension tasks in all the shared organizations. Your personal Azure DevOps might allow pipelines to execute only in one project space. If you're able to run pipelines in different projects in the same organization, you can set up the below pipeline anywhere within the shared organizations.
-
Create another repository in the same organization and project.
-
Create a new pipeline using the following steps:
-
Click the pipelines icon in the azure devops platform.
-
Click on
[ New Pipeline ]
button. -
Select following responses when prompted:
-
Where is your code: Azure Repos Git
-
Select the repository:
-
Configure your pipeline: Starter pipeline
-
-
-
Look for the
HelloWorld
andTwoSum
tasks in the tasks pane. And add them. -
Your final pipeline should look like below yaml.
trigger: # the current branch that you're in - main - master pool: vmImage: ubuntu-20.04 steps: - task: HelloWorld@0 - task: TwoSum@0 inputs: firstNumber: '7' secondNumber: '6'
Please refer to the successful release and test pipelines here.
If you face the below error message, please have a look at the Getting-Started document.
No hosted parallelism has been purchased or granted. To request a free parallelism grant, please fill out the following form https://aka.ms/azpipelines-parallelism-request
If you encounter other issues, please let our SMEs know about it 😊
Please consider checking if your program produces the expected output.
Possibly, you've forgotten to modify the logic inside the src > TwoSum > index.ts
file.
Please find the overview.md and modify it's contents to update the extension page.
Thank you for joining the session to learn and perform hands-on with the Azure DevOps Extension exercises. Learn more about building azure devops extensions and its advantages here.