How jenkinsci/cucumber-reports-plugin works
Project type and purpose
• This is a Maven-based Java Jenkins plugin (“cucumber-reports-plugin”).
• Its purpose is to hook into Jenkins builds, pick up Cucumber JSON test reports from the workspace, convert them into pretty HTML (using the external cucumber-reporting library), and expose those HTML pages in the build’s UI.
File structure
• Top-level artifacts:
• pom.xml (Maven build & plugin metadata)
• Jenkinsfile + .github/* (CI/CD pipeline and security scans)
• src/main/java/net/masterthought/jenkins:
• CucumberReportPublisher.java (the core Publisher extension)
• CucumberReportBaseAction, ProjectAction, RunAction (Jenkins Actions to render links & serve pages)
• SafeArchiveServingAction classes (serve HTML assets safely)
• src/main/resources:
• plugin.properties (plugin metadata)
• .jelly files under CucumberReportPublisher (UI configuration screens in Jenkins job config)
• Messages.properties (i18n)
• src/main/webapp: (static assets if any)
• There is no separate “backend” or “frontend” folder – the plugin embeds its UI via Jelly and serves HTML reports from generated files.
Key README insights
• The plugin registers itself as a Post-build publisher in Freestyle and Pipeline jobs.
• It provides both a configuration UI (Jelly help and config pages) and a DSL/Pipeline step.
• When the build finishes, it converts JSON → HTML via the cucumber-reporting library and persists them under the build’s artifacts directory.
• It then adds links to those reports in the Jenkins build sidebar.
Main components
a. Jenkins Core (Master)
b. cucumber-reports-plugin
• Configuration UI (Jelly pages in job config)
• Pipeline Step / Post-build Publisher
• Reporting Engine (invokes cucumber-reporting library)
• Actions (CucumberReportProjectAction, CucumberReportBaseAction, SafeArchiveServingAction) to register links and serve static content
c. Build Workspace (source of JSON reports)
d. Generated HTML Reports (artifact directory)
e. External Library: cucumber-reporting
f. User Browser (viewing Jenkins UI & HTML reports)
Relationships and interactions
1. User sets up a Freestyle or Pipeline job and configures the plugin via Jenkins UI (Jelly form) or DSL.
2. During build: tests run, cucumber configured with --plugin json -o cucumber.json → JSON report in workspace.
3. Post-build, Jenkins calls CucumberReportPublisher.publish():
– Reads JSON files from workspace (ant → fileIncludePattern/exclude)
– Passes data to the cucumber-reporting library
– Outputs HTML files to build’s report directory
4. Plugin registers Actions:
– ProjectAction adds a top-level “Cucumber Reports” link
– RunAction serves the overview feature HTML page
– SafeArchiveServingAction serves static resources (CSS/JS/images)
5. User clicks the link in the Jenkins UI → HTTP request routed via SafeArchiveServingAction → static HTML served.
Architectural patterns and design principles
• Jenkins Plugin Extension Points (Publisher, ProjectAction, RunAction)
• Separation of concerns:
• UI config (Jelly + properties) vs. processing logic (Java) vs. output (HTML artifacts)
• Reuse of an external reporting engine (cucumber-reporting library)
• Ant-style file pattern matching for inputs
Essential elements
• Plugin configuration entry point (Jelly UI & Pipeline step)
• JSON report discovery in workspace
• Reporting engine invocation
• HTML output storage location (build’s cucumber-html-reports folder)
• Jenkins Actions that add links & serve content
• Browser interaction with served HTML
• External dependency (cucumber-reporting library)