Suppose we want to start documenting the changelog, so we can easily track what new features, improvements, bugfixes are delivered in each version. To do that, we need to list the tickets done on every release version.
For this article, we want the changelog note to contain: service name, version, and list of tickets done.
Amazing Service 1.2.0
Features
Techdebt
Bugfix
Other
Imagine the manual work needed to do this:
- list the branches/tickets being merged to current release
- write the changelog
- post to Ms Teams channel
It must be done for every release version. Even doing it for a single service is already a chore. More so if you need to do it for many services, it’ll be hell. Our time will just be spent for administrative task instead of pushing our iterations quicker.
If you’re facing the same problem and already using Jenkins and Ms Teams, then this post may be for you.
Prerequisites
- Using Jenkins with Office365 Connector and this pipeline library:
https://github.com/griddynamics/mpl#use-standard-pipeline-but-with-custom-module - Using Ms Teams channel to post the releases
- Already use git tag to annotate each release
- Using maven release plugin and maven deploy
How to
Suppose we have this kind of merge commits between version 1.1.0 and 1.2.0:
- Merge feature/PROJECT-1232 to release/1.2
- Merge techdebt/PROJECT-1241-improve-query-performance to release/1.2
- Merge feature/PROJECT-1231 to release/1.2
- Merge bugfix/PROJECT-1252-fix-intermittent-error to release/1.2
- Merge bugfix/PROJECT-1251 to release/1.2
- Merge PROJECT-1301 to release/1.2
In general, we need to:
- Create a project-specific configuration in Jenkinsfile
- Create a step file: {ProjectRepo}/.jenkins/modules/{Stage}/{Name}{Stage}.groovy (name could be empty)
- Fill the step with our changelog notification code: we can use CFG config object & MPL functions inside the steps definition
For this case, we will use “Deploy” step with path .jenkins/modules/Deploy/Deploy.groovy.
We can check other standard steps on Jenkins Modular Pipeline Library repo: https://github.com/griddynamics/mpl/tree/master/resources/com/griddynamics/devops/mpl/modules
1. Configure some project-specific settings
ticketingUrlis, like the name suggests, the base URL of your ticketing system or issue tracker e.g. Github Issues, Jira, etc.teamsWebhookUrlis the webhook URL of your teams channel which will be notified with changelog posts.
2. Create the step file
Path: .jenkins/modules/Deploy/Deploy.groovy
We want to make sure the changelog is only posted to Teams on a successful release, and not during snapshot.
That means we need to execute extra logic after the original “Deploy” step.
Assuming params.RELEASE_TYPE will have value RELEASE on a release build, then:
3. Generate changelog & send notification to Teams
Next, we extract branch names from merge commits between previous tag and latest commit for further processing.
branches value would be something like:
We then group branches by their type (feature, techdebt, bugfix, etc).
groupedBranches value would be something like:
Next is generating the markdown for the body of the Teams post. We simply list the ticket number and the description under each type.
Then the generated markdown would be something like:
Finally, post using office365 connector:
Result
For example above, once the release build is finished and deployed, Jenkins will automatically notify the changelog to the Ms Teams channel.
Amazing Service 1.2.0
Feature
Techdebt
- PROJECT-1241 - improve query performance
Bugfix
- PROJECT-1252 - fix intermittent error
- PROJECT-1251
Etc
This article show and example to generate a changelog and send it to a Teams channel. Using a similar method, we can send the changelog to almost anywhere with a HTTP API easily using curl or supported plugins.