DEV Community

Cover image for Generate Releases Notes easily
Antoine
Antoine

Posted on • Edited on

Generate Releases Notes easily

Photo by Aaron Burden on Unsplash

I came on this post about using 2 tasks to generate release notes on Azure DevOps, and just want to share it with you.

Generate Notes in Build

You can easily add the task Generate Release Notes (Crossplatform) to your build and use the template suggested by the author, as inline template.

# Notes for build 
**Build Number**: {{buildDetails.id}}
**Build Trigger PR Number**: {{lookup buildDetails.triggerInfo 'pr.number'}} 

# Associated Pull Requests ({{pullRequests.length}})
{{#forEach pullRequests}}
{{#if isFirst}}### Associated Pull Requests (only shown if  PR) {{/if}}
*  **PR {{this.id}}**  {{this.title}}
{{/forEach}}

# Builds with associated WI/CS ({{builds.length}})
{{#forEach builds}}
{{#if isFirst}}## Builds {{/if}}
##  Build {{this.build.buildNumber}}
{{#forEach this.commits}}
{{#if isFirst}}### Commits {{/if}}
- CS {{this.id}}
{{/forEach}}
{{#forEach this.workitems}}
{{#if isFirst}}### Workitems {{/if}}
- WI {{this.id}}
{{/forEach}} 
{{/forEach}}

# Global list of WI ({{workItems.length}})
{{#forEach workItems}}
{{#if isFirst}}## Associated Work Items (only shown if  WI) {{/if}}
*  **{{this.id}}**  {{lookup this.fields 'System.Title'}}
  - **WIT** {{lookup this.fields 'System.WorkItemType'}} 
  - **Tags** {{lookup this.fields 'System.Tags'}}
{{/forEach}}

{{#forEach commits}}
{{#if isFirst}}### Associated commits{{/if}}
* ** ID{{this.id}}** 
  -  **Message:** {{this.message}}
  -  **Commited by:** {{this.author.displayName}} 
  -  **FileCount:** {{this.changes.length}} 
{{#forEach this.changes}}
      -  **File path (TFVC or TfsGit):** {{this.item.path}}  
      -  **File filename (GitHub):** {{this.filename}}  
{{/forEach}}
{{/forEach}}
Enter fullscreen mode Exit fullscreen mode

It will generate a file to $(Build.ArtifactStagingDirectory)/releasenotes.md and you can publish it using the Publish task.

Generate Notes in Release

Like in the previous section, we can use the same tasks to generate the release notes.
But we want to aggregate it.

The task Git based WIKI Single File Updater from Black Marble is also available to update Azure DevOps Wiki with file. Let's use it !

We need to fill a lot of information.

Wiki

  • Wiki repository

Go to the Wiki.
By clicking on the 3 dots in the Azure DevOps Wiki, you will be able to clone the Repository and get its url.

Get the clone button

  • Branch

Just use the default branch (master) and leave the branch empty.

  • Page name

For the name of the page, you can leverage predefined variables in Azure DevOps to generate one different page each time.

For example : $(Release.DeploymentName)-$(Release.DeploymentID).md

Git

Fill an explicit Git Name and Git Email as the will be written to track the update of your wiki.

Azure DevOps credentials

I recommend to create a variable group to store your username and the Personal Access Token used for authentication. It will be easier for you to track and reuse them, if needed.

Go create a variable group, and add both username and Personal Authentication Token as secrets.

To generate the Personal Access Token:

  • click on User Settings
  • click on Personal access tokens
  • click on New Token
  • Grant only Read & Write authorization
  • Copy the token in the secret variable

Troubleshooting page in case of issues.

Hope this helps !

Top comments (0)