# jenkinsci/cucumber-reports-plugin architecture

> Architecture diagram of the GitHub repository jenkinsci/cucumber-reports-plugin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jenkinsci/cucumber-reports-plugin
- Repository: https://github.com/jenkinsci/cucumber-reports-plugin

## Overview

##### 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)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clusters
    subgraph "Jenkins Core" 
        direction TB
        JenkinsUI["Jenkins UI"]:::jenkins
        JenkinsLifecycle["Jenkins Build Lifecycle"]:::jenkins
    end

    subgraph "Build Workspace"
        direction TB
        Workspace["Workspace JSON Reports"]:::artifacts
    end

    subgraph "cucumber-reports-plugin" 
        direction TB
        subgraph "Configuration UI" 
            direction TB
            JellyUI["Jelly Views & Help"]:::plugin
        end
        subgraph "Publisher Extension"
            direction TB
            Publisher["CucumberReportPublisher"]:::plugin
            Descriptor["CucumberReportDescriptor"]:::plugin
        end
        subgraph "Jenkins Actions"
            direction TB
            ProjectAction["CucumberReportProjectAction"]:::plugin
            BaseAction["CucumberReportBaseAction"]:::plugin
            SafeServe["SafeArchiveServingAction"]:::plugin
            SafeServeRun["SafeArchiveServingRunAction"]:::plugin
        end
        subgraph "Reporting Engine"
            direction TB
            ExternalLib["cucumber-reporting Library"]:::external
        end
        subgraph "Static Assets"
            direction TB
            Webapp["Webapp Static Files"]:::plugin
        end
    end

    subgraph "HTML Artifacts"
        direction TB
        HtmlDir["cucumber-html-reports Directory"]:::artifacts
    end

    subgraph "User Browser"
        direction TB
        Browser["User Browser"]:::browser
    end

    %% Connections
    JenkinsUI -->|"configures via UI/Dsl"| JellyUI
    Workspace -->|"reads JSON reports"| Publisher
    Publisher -->|"invokes"| ExternalLib
    ExternalLib -->|"generates HTML"| HtmlDir
    HtmlDir -->|"served by"| SafeServe
    HtmlDir -->|"served by"| SafeServeRun
    Publisher -->|"registers actions"| ProjectAction
    Publisher -->|"registers actions"| BaseAction
    JenkinsLifecycle -->|"post-build hook"| Publisher
    Browser -->|"clicks link"| ProjectAction
    Browser -->|"HTTP request"| SafeServe
    Browser -->|"HTTP request"| SafeServeRun

    %% Click Events
    click MavenPluginDef "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/pom.xml"
    click MavenPluginDef "https://github.com/jenkinsci/cucumber-reports-plugin/tree/master/Jenkinsfile"
    click MavenPluginDef "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/.github/workflows/jenkins-security-scan.yml"
    click PluginMetadata "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/src/main/resources/plugin.properties"
    click PluginMetadata "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/src/main/resources/net/masterthought/jenkins/Messages.properties"
    click JellyUI "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/src/main/resources/net/masterthought/jenkins/CucumberReportPublisher/config.jelly"
    click JellyUI "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/src/main/resources/net/masterthought/jenkins/CucumberReportPublisher/*.html"
    click JellyUI "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/src/main/resources/net/masterthought/jenkins/CucumberReportPublisher/Classification/*.jelly"
    click JellyUI "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/src/main/resources/net/masterthought/jenkins/CucumberReportPublisher/Classification/*.html"
    click JellyUI "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/src/main/resources/index.jelly"
    click Publisher "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/src/main/java/net/masterthought/jenkins/CucumberReportPublisher.java"
    click Descriptor "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/src/main/java/net/masterthought/jenkins/CucumberReportDescriptor.java"
    click ProjectAction "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/src/main/java/net/masterthought/jenkins/CucumberReportProjectAction.java"
    click BaseAction "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/src/main/java/net/masterthought/jenkins/CucumberReportBaseAction.java"
    click SafeServe "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/src/main/java/net/masterthought/jenkins/SafeArchiveServingAction.java"
    click SafeServeRun "https://github.com/jenkinsci/cucumber-reports-plugin/blob/master/src/main/java/net/masterthought/jenkins/SafeArchiveServingRunAction.java"
    click Webapp "https://github.com/jenkinsci/cucumber-reports-plugin/tree/master/src/main/webapp"

    %% Styles
    classDef jenkins fill:#ADD8E6,stroke:#000;
    classDef plugin fill:#90EE90,stroke:#000;
    classDef external fill:#FFDAB9,stroke:#000;
    classDef artifacts fill:#D3D3D3,stroke:#000;
    classDef browser fill:#FFFFE0,stroke:#000;
```
