Monitor software version changes with Huginn
Huginn is a great piece of software, but the documentation is ... a bit sparse. Especially when it comes to details of the agents. I'm going to blog about a couple more more examples in the future.
For another project I'm using Leaflet, a JavaScript library for rendering maps in a browser. New versions are released occasionally, and I want to know when it's time to update the project website. Huginn can do that.
This needs three agents:
Checking for new versions: Http Status Agent
This agent is used to periodically check the website and see if there is a new released version.
In this case I'm using the GitHub repository as source, and there the "latest" link. The "Releases" page has a "Latest release" link (https://github.com/Leaflet/Leaflet/releases), which is a redirect to the actual version (currently: https://github.com/Leaflet/Leaflet/releases/tag/v1.7.1).
The Huginn agent is configured as follow:
- Schedule: pick one, I'm using a weekly time
- Keep events: I keep events around for 7 days, for debugging purposes
- Url: https://github.com/Leaflet/Leaflet/releases/latest
- Disable redirect follow: False
- Changes only: True
By disabling "Disable redirect follow" the agent will follow the redirect, and provide the final link in "final_url". And by enabling "Changes only" this agent is only emitting events when something changes - a new version is released.
Formatting the data: Event Formatting Agent
The incoming data from the Http Status Agent looks like this:
{
"url": "https://github.com/Leaflet/Leaflet/releases/latest",
"response_received": true,
"elapsed_time": 0.5510568432509899,
"final_url": "https://github.com/Leaflet/Leaflet/releases/tag/v1.7.1",
"redirected": true,
"status": "200"
}
What I need is the version information after "tag/". The Formatting Agent can do that using the "matchers". As source specify the output from the Http Status Agent above. As Options the following
{
"instructions": {
"agent": "{{agent.type}}",
"version_regexp_data": "{{version}}",
"version_string": "{{version.1}}"
},
"matchers": [
{
"path": "{{final_url}}",
"regexp": ".+tag.(.+)",
"to": "version"
}
],
"mode": "merge"
}
The "matchers" will extract everything after "tag/" using a regexp, and store the information in "version". The "instructions" creates new variables using the data from the match.
Notify: Email Agent
As input use the output from the Event Formatting Agent. I'm using the following options:
{
"subject": "Leaflet version change: {{version_string}}",
"expected_receive_period_in_days": "365",
"content_type": "text/html",
"body": "<br/>New Leaflet version: {{version_string}}"
}
This creates a short email, with the new version information included.
Comments
Display comments as Linear | Threaded