GitHub Action
Jenkins status alerts and reporting
Create a Github Action that monitors the status of Jenkins and generates Markdown reports for your inventory. It also alerts you when the nodes are not functioning properly.
Let's face it, monitoring the status of Jenkins can be a real headache. If your nodes aren't functioning properly, it can quickly turn into a full-blown migraine. But fear not, dear developers, for there's a new Github Action in town that will save you from the agony of manual monitoring.
Introducing the Github Action that monitors the status of Jenkins and generates Markdown reports for your inventory. This little gem not only keeps an eye on your Jenkins nodes, but it also compiles easy-to-read reports so that you can stay on top of your inventory status with ease.
And if that wasn't enough to make you jump for joy, the Github Action also create issues when it detects that your nodes aren't functioning properly. Now you can sit back, relax, and let this trusty assistant take care of the dirty work for you.
soon
- Easy to use with great customization
- Reporting in Markdown with essential information (Disk usage, JVM version...)
- Self-hosted: The reporting data is stored in json format (including previous records) in the repo itself.
- Generate an issue (assignation, labels..) when machines are offline, including links to the Jenkins Dashboard.
- Close the issue when the machine is back online
- Extend the markdown template with you own content by using tags
- Easy to modify the files and ensure the integrity with Json Schemas
- The report data is exported as an output and can be used in the pipeline
- Generate an issue if the disk usage is above a certain level, auto-close when the disk usage is back to normal
- Great test coverage (in progress)
Sample Report
Sample Issue
soon
With this workflow you get them most of this action:
- Trigger manual or by Cron job every Day
- It will generate a detailed report
- It will store the database in the repo
- It will generate an issue per machine that is down
- It will close the issue if the machine is back online
name: 'Jenkins Monitoring'
on:
# Scheduled trigger
schedule:
# Run every Day at 00:00
- cron: '0 0 * * *'
# Manual trigger
workflow_dispatch:
permissions:
# Write access in order to update the local files with the reports
contents: write
pull-requests: none
# Write access in order to create issues
issues: write
packages: none
jobs:
jenkins-status:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Jenkins status alerts and reporting
uses: UlisesGascon/jenkins-status-alerts-and-reporting@v1.4.0
id: jenkins-status-alerts-and-reporting
with:
database: experimental/database.json
jenkins-domain: 'jenkins.example.com'
jenkins-username: ${{ secrets.JENKINS_USERNAME }}
jenkins-token: ${{ secrets.JENKINS_TOKEN }}
# Issues
generate-issue: true
issue-assignees: 'UlisesGascon'
issue-labels: 'incident,machine-down'
auto-close-issue: true
disk-alert-level: 90
# Report
report: experimental/jenkins-report.md
report-tags-enabled: true
# Git changes
auto-commit: true
auto-push: true
github-token: ${{ secrets.GITHUB_TOKEN }}
jenkins-domain
: The domain name of your Jenkins server without the protocol or trailing slash, likejenkins.example.com
jenkins-username
: The username of the Jenkins userjenkins-token
: The API token of the Jenkins userdatabase
: Defines the path to the json file usage to store the nodes informationreport
: Defines the path where the markdown report will be added/updatedauto-commit
: Commits the changes in thedatabase
andreport
filesauto-push
: Pushes the code changes to the branchgenerate-issue
: Create an issue per machine that is downissue-assignees
: List of assignees for the issueissue-labels
: List of labels for the issueauto-close-issue
: Close the issue when the machine is back onlinegithub-token
: The token usage to create the issue and push the codereport-tags-enabled
: Defines if the markdown report must be created/updated around tags by default is disabled. This is useful if the report is going to be include in a file that has other content on it, like docusaurus docs site or similar.report-start-tag
: Defines the start tag, default<!-- JENKINS-REPORTING:START -->
report-end-tag
Defines the closing tag, default<!-- JENKINS-REPORTING:END -->
create-issues-for-new-offline-nodes
: Automatically generate an issue if the node is offline and has not been previously recorded in the databasedisk-alert-level
: Disk usage level to generate an alert
computers
: The list of Jenkins computers with all the details (same as the database content)
name: 'OpenSSF Scoring'
on:
# ...
permissions:
# ...
jobs:
jenkins-status:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Jenkins status alerts and reporting
uses: UlisesGascon/jenkins-status-alerts-and-reporting@v1.4.0
id: jenkins-status
with:
# ....
- name: Print the Computers
run: |
echo '${{ steps.jenkins-status.outputs.computers }}'
If you want to avoid creating issues for the machines that are already down in your infra on the first run, use create-issues-for-new-offline-nodes=false
If you want to mix the report in markdown format with other content, then you can use report-tags-enabled=true
then report file will use the tags to add/update the report summary without affecting what is before or after the tagged section.
This is very useful for static websites.
By default we use <!-- JENKINS-REPORTING:START -->
and <!-- JENKINS-REPORTING:END -->
, but this can be customize by adding your custom tags as report-start-tag
and report-end-tag
Just for reference, the database will store the current Jenkins nodes in this shape:
{
"test-azure_msft-ubuntu1604_arm_cross-x64-1": {
"name": "test-azure_msft-ubuntu1604_arm_cross-x64-1",
"description": "Ubuntu 16.04 LTS with Raspberry Pi cross compilers installed",
"diskUsage": null,
"architecture": null,
"monitorVersion": null,
"isOffline": true,
"isTemporarilyOffline": false,
"offlineCauseReason": "",
"isIdle": true
}
}