Complete the code to enable test result trend reporting in Jenkins pipeline.
post {
always {
junit '[1]'
}
}The junit step in Jenkins expects the path to the test result XML files, usually matching test-results/*.xml.
Complete the code to archive test result reports after the build.
archiveArtifacts artifacts: '[1]', fingerprint: true
Archiving test result XML files allows Jenkins to keep a record of test reports for trend analysis.
Fix the error in the pipeline code to correctly publish test result trends.
pipeline {
agent any
stages {
stage('Test') {
steps {
sh 'run-tests.sh'
}
}
}
post {
always {
junit '[1]'
}
}
}The junit step requires the path to XML test result files. Using test-results/*.xml matches the correct files.
Fill both blanks to create a map of test names to their pass/fail status for trend analysis.
def testStatus = [[1]: [2] for test in tests]
To map test names to their status, use test.name as key and test.status as value.
Fill all three blanks to filter and map only failed tests for detailed reporting.
def failedTests = [[1]: [2] for [3] in tests if [2] == 'FAILED']
Use test.name as key, test.status as value, and iterate with test variable to filter failed tests.