Hi,
I have executed Katalon automated tests via Jenkins. I m not able to view the HTML report in Jenkins . It is showing blank page when clicked on HTML report option or widget present in Jenkins Dashboard. Please provide steps and provide any other solutions are available to view the report.
It shows the usage of HTML Publisher plugin to see reports generated using integrated tools like sonaryqube , codecoverage , protractor.. .
Using this jenkins plugin we can see the reports from within jenkins.
We will use sample ruby project , and will create jenkins pipeline for it. we are doing code coverage over this project and will publish the code coverage results with each build job. I could.
STEPS INVOLVED
Configure your pipeline under Jenkins1. Creation of Pipeline Project
Go to NEW ITEM under Jenkins and choose appropriate name for the project and choose project type as pipeline.
Go to the Pipeline section of Advance Project Options and enter below code :-
stage ‘Build’
node {
// Checkout
git branch: ‘master’,url: ‘//github.com/devops81/HTMLPublisher.git’
// install required bundles
sh ‘bundle install’
// build and run tests with coverage
sh ‘bundle exec rake build spec’
// Archive the built artifacts
archive (includes: ‘pkg/*.gem’)
}
Till this point if we build the project it will do following things
i) Checkout the codebase
ii)Execute the bundle install command
iii)Execute the command bundle exec rake build spec which will compile test and generate the artifact file
2. Generating pipeline code for HTML Publisher plugin
Next we will use Snippet Generator to generate code for HTML Publisher plugin go to the url :-
Under SAMPLE STEP choose publishHTML:Publish HTML reports and provide the values for these fields :-
- HTML directory to archive
- Index page[s]
- Report title
Next click on Generate Pipeline Script it will generate script for the html publisher plugin with the provided values.
3. Integrating the generated html publisher code with existing pipeline code
Next we will copy the code which got generated and will append it to our existing pipeline code
Final code should look like below
stage ‘Build’
node {
// Checkout
git branch: ‘master’,url: ‘//github.com/devops81/HTMLPublisher.git’
// install required bundles
sh ‘bundle install’
// build and run tests with coverage
sh ‘bundle exec rake build spec’
// Archive the built artifacts
archive (includes: ‘pkg/*.gem’)
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: ‘coverage’, reportFiles: ‘index.html’, reportName: ‘HTML Report’, reportTitles: ‘Coverage Report’])
}
After click on Apply and Save button on Jenkins.
4. Viewing the report post successful Jenkins job run
Next we can run the job post successful run of the job the left section of the Jenkins should show link for html report got generated during the build.
Jenkins is one of the most popular CI/CD tools for automating builds and deployments. It is very flexible and can be deployed on almost every operating system, as well as on Red Hat OpenShift. This article shows you how to deploy Jenkins on OpenShift 4.9, create a simple pipeline to deploy a Java application to OpenShift, do some testing, save the test results as HTML, and publish it as an artifact so that people can see the results.
For this scenario, we'll generate an HTML report using Maven OWASP Dependency Check plugins. The report will contain a list of libraries that contain vulnerabilities. This pipeline runs on Jenkins 2.2 on top of OpenShift 4.9.
Use Jenkins to generate a report on OpenShift 4
There are multiple ways to set up Jenkins on OpenShift 4. This article uses a template provided by the OpenShift Developer Catalog.
First, check whether the Jenkins template is available in OpenShift:
$ oc get template -n openshift | grep jenkinsIf Jenkins templates are available, you'll get output such as:
jenkins-ephemeral Jenkins service, without persistent storage.... 8 (all set) 7 jenkins-ephemeral-monitored Jenkins service, without persistent storage. ... 9 (all set) 8 jenkins-persistent Jenkins service, with persistent storage.... 10 (all set) 8 jenkins-persistent-monitored Jenkins service, with persistent storage. ... 11 (all set) 9Now let's try to spawn a Jenkins ephemeral report. In this case, ephemeral means that the service is not storing its data. The ephemeral approach is good for a nonproduction environment. The following command creates Jenkins instances in the CI/CD namespace:
$ oc new-app --template=jenkins-ephemeral -n cicdCheck the created route to see the exact URL for the newly created Jenkins instances. Then open that URL and log in with your OpenShift credentials.
Building and running a pipeline
Start creating a build pipeline by selecting a Pipeline icon in your Jenkins instance, as shown in Figure 1.
Next, paste the following code into the Pipeline script, as shown in Figure 2:
node('maven') { stage ('pull code') { sh "git clone //github.com/edwin/hello-world-java-docker.git source" } stage ('build') { dir("source") { sh "mvn -Dmaven.repo.local=/tmp/m2 org.owasp:dependency-check-maven:check" } } stage ('generate report') { dir("source") { publishHTML (target: [ allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'target', reportFiles: 'dependency-check-report.html', reportName: "Application-Dependency-Check-Report" ]) } } }Now focus on the "generate report" stage, where you save your HTML report as a build artifact. Press the Build Now button, highlighted in Figure 3, to trigger the pipeline.
And now the HTML report appears in the menu bar on the left, as shown in Figure 4.
Clicking on the report button displays the contents of the generated HTML report, as illustrated in Figure 5.
If you find that your report shows some errors or is a bit disorganized, there's a workaround to fix it. Go to Script Console inside the Manage Jenkins menu, as shown in Figure 6.
Type the following script inside the Script Console text field and then press the Run button.
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")Conclusion
In addition to automating your CI/CD process, Jenkins can automate the recording of events that occur during its own run. This article has illustrated several parts of the open source environment that make it easy to generate and save reports from Jenkins.