Create automatic release notes on AzureDevOps
As part of our release process, we need to aggregate all work items resolved or closed. It’s a nightmare if we need to made this manually.
So today we are going to see how to create a release notes wiki automatically during the release process.
Install this pipeline task
Install it on your organisation
Prepare your release
Name it “Publish release notes”
Add “Generate release notes” and “PowerShell” tasks.
Configure Generate Release Notes
Add this content to “Template” ( Some sample are available here).
#Release notes for build $defname
**Build Number** : $($build.buildnumber)
**Build started** : $("{0:dd/MM/yy HH:mm:ss}" -f [datetime]$build.startTime)
**Source Branch** : $($build.sourceBranch)
###Associated change sets/commits
@@CSLOOP@@
* **ID $($csdetail.changesetid)$($csdetail.commitid)** $($csdetail.comment)
@@CSLOOP@@
Now the markdown file is written to “releasenotes.md”
Create wiki page
We are using this API : https://docs.microsoft.com/fr-fr/rest/api/azure/devops/wiki/pages/create%20or%20update?view=azure-devops-rest-5.0#add_a_page for adding a wiki page.
Go to your “PowerShell” task.
Add this script
# Get content of releasenotes
$content = [IO.File]::ReadAllText("$(System.DefaultWorkingDirectory)\releasenotes.md")# Get content of package.json for getting version value
$contentPackage = [IO.File]::ReadAllText("$(System.DefaultWorkingDirectory)\package.json") | ConvertFrom-Json;# Concat the URI
$uri = $env:WikiUri +$env:WikiPath + $($contentPackage.version)# Convert to json for Wiki API
$data = @{content=$content;} | ConvertTo-Json;# Set Request
$params = @{uri = "$($uri)";
Method = 'PUT';
Headers = @{Authorization = "Basic $($env:basicB64Token)" };
ContentType = "application/json";
Body = $data;
}# Call
Invoke-WebRequest @params
Set ENV VAR
WikiUri : It’s the uri to Wiki API.
https://dev.azure.com/{organization}/{project}/_apis/wiki/wikis/{wikiIdentifier}/pages?api-version=5.0-preview.1&path=WikiPath: It’s the path where you will be creating the wiki page
For example : Release%20notes/basicB64Token : It’s your personal token encoded with Base64.
Convert “ :{token}“ to base64.
Read this article for create ithttps://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts
Here you go, now whenever a release is triggered, the associated release note is automatically created in the configured Wiki.