Articles

Improved Allure-report-plugin in Jenkins pipeline to display Graph trend

The problem was, that when in Jenkins build no pass (green) builds presented, the trend was not displayed and the Allure report menu item was missed (as result Dashboards iFrames based on Allure report were missing too).

Root problem: Miscommunication between Jenkins statuses and handle of those statuses.

Allure-report-plugin builds are expected to be finished not in Failed status but in Unstable.

Below is the groove script with logic implementation:

markUnstableIfFailed() {
try {
echo "Check Flag to mark build as Unstable if it Failed: $unstableIfFailed"
if (unstableIfFailed) {
echo "Set build Unstable if Failded for Allure report trend generate"
if (currentBuild.currentResult == 'FAILURE') {
currentBuild.rawBuild.@result = hudson.model.Result.UNSTABLE
}
}
} catch (err) {
err.printStackTrace()
}
}

Note 1: This improvement makes sense only for pipeline builds (which work based on groovy script)

Note 2: To make the new groovy script work in Jenkins, you need to go to Jenkins - Main - Manage Jenkins - Scripts Approvals and approve the corresponding script

We now have in Allure: