0
0
Jenkinsdevops~30 mins

HTML reports publishing in Jenkins - Mini Project: Build & Apply

Choose your learning style9 modes available
HTML Reports Publishing in Jenkins
📖 Scenario: You are working as a DevOps engineer. Your team runs automated tests that generate HTML reports. You want to publish these HTML reports in Jenkins so everyone can see the test results easily.
🎯 Goal: Learn how to configure a Jenkins job to publish HTML reports generated by automated tests.
📋 What You'll Learn
Create a Jenkins job configuration snippet with HTML report directory
Add a configuration variable for the report directory path
Write the Jenkins pipeline step to publish the HTML report
Print the Jenkins pipeline snippet that publishes the HTML report
💡 Why This Matters
🌍 Real World
Publishing HTML reports in Jenkins helps teams easily view test results and other reports directly in the Jenkins interface without searching files manually.
💼 Career
Knowing how to configure Jenkins to publish HTML reports is a key skill for DevOps engineers and automation specialists to improve visibility and feedback in CI/CD pipelines.
Progress0 / 4 steps
1
Create Jenkins job configuration snippet for HTML reports
Create a variable called htmlReportConfig that contains the Jenkins job configuration snippet as a string. It should include the publishHTML block with reportDir set to "target/surefire-reports" and reportFiles set to "index.html".
Jenkins
Need a hint?

Use triple quotes to create a multi-line string. Include publishHTML with reportDir and reportFiles exactly as shown.

2
Add a configuration variable for the report directory path
Create a variable called reportDirectory and set it to the string "target/surefire-reports". Then update the htmlReportConfig string to use this variable inside the reportDir field using string interpolation.
Jenkins
Need a hint?

Use an f-string for htmlReportConfig so you can insert the reportDirectory variable inside the string.

3
Write the Jenkins pipeline step to publish the HTML report
Create a variable called pipelineStep that contains the Jenkins pipeline step code as a string. It should call publishHTML with reportDir set to reportDirectory, reportFiles set to "index.html", and reportName set to "Test Report". Use string interpolation to insert reportDirectory.
Jenkins
Need a hint?

Use triple quotes and an f-string to create the pipelineStep string with the correct Jenkins pipeline syntax.

4
Print the Jenkins pipeline snippet that publishes the HTML report
Write a print statement to display the contents of the pipelineStep variable.
Jenkins
Need a hint?

Use print(pipelineStep) to show the Jenkins pipeline snippet.