Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Generate and save an HTML report in Jenkins on OpenShift 4

March 30, 2022
Muhammad Edwin
Related topics:
CI/CD
Related products:
Red Hat OpenShift

     

    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 jenkins

    If 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)      9

    Now 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 cicd

    Check 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.

    Screenshow showing how to create a Pipeline in the Jenkins console.
    Figure 1: Create a Pipeline in the Jenkins console.

    Next, paste the following code into the Pipeline script, as shown in Figure 2:

    node('maven') {
    
        stage ('pull code') {
    
            sh "git clone https://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"
    
                ])
    
            }
    
        }
    
    }
    Screenshow showing the script being inserted into a Pipeline script.
    Figure 2: The script should be inserted into a Pipeline Script.

    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.

    Screenshow showin ghow the Pipeline's web page lets you build the Pipeline.
    Figure 3: The Pipeline's web page lets you build the Pipeline.

    And now the HTML report appears in the menu bar on the left, as shown in Figure 4.

    Screenshot showing that a report appears in the menu of the Pipeline web page.
    Figure 4: A report appears in the menu of the Pipeline web page.

    Clicking on the report button displays the contents of the generated HTML report, as illustrated in Figure 5.

    Screenshot of a formatted report displayed on the web page.
    Figure 5: A formatted report is displayed on the web page.

    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.

    Screenshot showing that the Script Console is available in Tools and Actions.
    Figure 6: The Script Console is available in Tools and Actions.

    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.

    Last updated: September 20, 2023

    Recent Posts

    • Red Hat Hardened Images: Top 5 benefits for software developers

    • How EvalHub manages two-layer Kubernetes control planes

    • Tekton joins the CNCF as an incubating project

    • Federated identity across the hybrid cloud using zero trust workload identity manager

    • Confidential virtual machine storage attack scenarios

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.