# jenkinsci/groovy-plugin architecture

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

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

## Overview

The Jenkins Groovy plugin offers three execution routes: freestyle Groovy builds, privileged in-process System Groovy builds, and a Pipeline `withGroovy` step. Freestyle scripts come from workspace files or configured text and run through the Groovy command; System Groovy evaluates secure scripts inside Jenkins with build bindings. Administrators configure Groovy installations, and the plugin also documents optional token-macro evaluation. The graph preserves these distinct routes and source types. Edges are limited to relationships shown in the README or sampled source; unsampled behavior is not inferred.

Main entry points: [`src/main/java/hudson/plugins/groovy/Groovy.java`](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/Groovy.java) (Groovy builder), [`src/main/java/hudson/plugins/groovy/SystemGroovy.java`](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/SystemGroovy.java) (System Groovy builder), [`src/main/java/hudson/plugins/groovy/ScriptSource.java`](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/ScriptSource.java) (Script source API), [`src/main/java/hudson/plugins/groovy/WithGroovyStep.java`](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/WithGroovyStep.java) (withGroovy step)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_freestyle["Freestyle execution"]
  node_groovy_builder["Groovy builder<br/>[Groovy.java]"]
  node_builder_base["Builder base"]
  node_script_source["Script source API<br/>[ScriptSource.java]"]
  node_inline_source["Inline script source"]
  node_file_source["Workspace file source"]
end

subgraph group_system["System Groovy"]
  node_system_builder["System Groovy builder<br/>[SystemGroovy.java]"]
  node_system_source["System source API"]
  node_system_inline["Secure inline source"]
  node_system_file["Secure file source"]
end

subgraph group_pipeline["Pipeline integration"]
  node_pipeline_step["withGroovy step"]
  node_pipeline_script["Pipeline script resource<br/>[Pipeline.groovy]"]
end

subgraph group_config["Tools and extensions"]
  node_installation["Groovy installation"]
  node_installer["Groovy installer"]
  node_token_macro["Token macro extension"]
end

node_user(("Jenkins user"))
node_groovy_cli["Groovy command"]
node_jenkins_runtime["Jenkins runtime"]

node_user -->|"configures build"| node_groovy_builder
node_groovy_builder -->|"loads script"| node_script_source
node_groovy_builder -->|"selects tool"| node_installation
node_groovy_builder -->|"launches script"| node_groovy_cli
node_builder_base -->|"exposes source options"| node_script_source
node_inline_source -->|"implements source"| node_script_source
node_file_source -->|"implements source"| node_script_source
node_system_builder -->|"gets secure script"| node_system_source
node_system_builder -->|"evaluates script"| node_jenkins_runtime
node_system_inline -->|"implements source"| node_system_source
node_system_file -->|"implements source"| node_system_source
node_user -->|"configures build"| node_system_builder
node_user -->|"uses pipeline step"| node_pipeline_step
node_pipeline_step -->|"resolves tool"| node_installation
node_pipeline_step -->|"copies resource"| node_pipeline_script
node_installation -->|"offers installer"| node_installer
node_user -.->|"enables integration"| node_token_macro
node_token_macro -->|"evaluates as system script"| node_system_builder

click node_groovy_builder "https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/Groovy.java"
click node_builder_base "https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/AbstractGroovy.java"
click node_script_source "https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/ScriptSource.java"
click node_inline_source "https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/StringScriptSource.java"
click node_file_source "https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/FileScriptSource.java"
click node_system_builder "https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/SystemGroovy.java"
click node_system_source "https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/SystemScriptSource.java"
click node_system_inline "https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/StringSystemScriptSource.java"
click node_system_file "https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/FileSystemScriptSource.java"
click node_pipeline_step "https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/WithGroovyStep.java"
click node_pipeline_script "https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/resources/hudson/plugins/groovy/Pipeline.groovy"
click node_installation "https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/GroovyInstallation.java"
click node_installer "https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/GroovyInstaller.java"
click node_token_macro "https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/GroovyTokenMacro.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_groovy_builder,node_builder_base,node_script_source,node_inline_source,node_file_source,node_user toneBlue
class node_system_builder,node_system_source,node_system_inline,node_system_file toneAmber
class node_pipeline_step,node_pipeline_script toneMint
class node_installation,node_installer,node_token_macro toneRose
class node_groovy_cli,node_jenkins_runtime toneIndigo
```

## Components

### Freestyle execution

- [Groovy builder](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/Groovy.java): `src/main/java/hudson/plugins/groovy/Groovy.java`
- [Builder base](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/AbstractGroovy.java): `src/main/java/hudson/plugins/groovy/AbstractGroovy.java`
- [Script source API](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/ScriptSource.java): `src/main/java/hudson/plugins/groovy/ScriptSource.java`
- [Inline script source](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/StringScriptSource.java): `src/main/java/hudson/plugins/groovy/StringScriptSource.java`
- [Workspace file source](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/FileScriptSource.java): `src/main/java/hudson/plugins/groovy/FileScriptSource.java`

### System Groovy

- [System Groovy builder](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/SystemGroovy.java): `src/main/java/hudson/plugins/groovy/SystemGroovy.java`
- [System source API](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/SystemScriptSource.java): `src/main/java/hudson/plugins/groovy/SystemScriptSource.java`
- [Secure inline source](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/StringSystemScriptSource.java): `src/main/java/hudson/plugins/groovy/StringSystemScriptSource.java`
- [Secure file source](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/FileSystemScriptSource.java): `src/main/java/hudson/plugins/groovy/FileSystemScriptSource.java`

### Pipeline integration

- [withGroovy step](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/WithGroovyStep.java): `src/main/java/hudson/plugins/groovy/WithGroovyStep.java`
- [Pipeline script resource](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/resources/hudson/plugins/groovy/Pipeline.groovy): `src/main/resources/hudson/plugins/groovy/Pipeline.groovy`

### Tools and extensions

- [Groovy installation](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/GroovyInstallation.java): `src/main/java/hudson/plugins/groovy/GroovyInstallation.java`
- [Groovy installer](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/GroovyInstaller.java): `src/main/java/hudson/plugins/groovy/GroovyInstaller.java`
- [Token macro extension](https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/GroovyTokenMacro.java): `src/main/java/hudson/plugins/groovy/GroovyTokenMacro.java`

### Other components

- **Jenkins user**
- **Groovy command**
- **Jenkins runtime**

## Connections

- Jenkins user → Groovy builder: configures build (evidence: `README.md`)
- Groovy builder → Script source API: loads script (evidence: `src/main/java/hudson/plugins/groovy/Groovy.java`)
- Groovy builder → Groovy installation: selects tool (evidence: `src/main/java/hudson/plugins/groovy/Groovy.java`)
- Groovy builder → Groovy command: launches script (evidence: `README.md`)
- Builder base → Script source API: exposes source options (evidence: `src/main/java/hudson/plugins/groovy/AbstractGroovy.java`)
- Inline script source → Script source API: implements source (evidence: `src/main/java/hudson/plugins/groovy/StringScriptSource.java`)
- Workspace file source → Script source API: implements source (evidence: `src/main/java/hudson/plugins/groovy/FileScriptSource.java`)
- System Groovy builder → System source API: gets secure script (evidence: `src/main/java/hudson/plugins/groovy/SystemGroovy.java`)
- System Groovy builder → Jenkins runtime: evaluates script (evidence: `src/main/java/hudson/plugins/groovy/SystemGroovy.java`)
- Secure inline source → System source API: implements source (evidence: `src/main/java/hudson/plugins/groovy/StringSystemScriptSource.java`)
- Secure file source → System source API: implements source (evidence: `src/main/java/hudson/plugins/groovy/FileSystemScriptSource.java`)
- Jenkins user → System Groovy builder: configures build (evidence: `README.md`)
- Jenkins user → withGroovy step: uses pipeline step (evidence: `README.md`)
- withGroovy step → Groovy installation: resolves tool (evidence: `src/main/java/hudson/plugins/groovy/WithGroovyStep.java`)
- withGroovy step → Pipeline script resource: copies resource (evidence: `src/main/java/hudson/plugins/groovy/WithGroovyStep.java`)
- Groovy installation → Groovy installer: offers installer (evidence: `src/main/java/hudson/plugins/groovy/GroovyInstallation.java`)
- Jenkins user → Token macro extension: enables integration (evidence: `README.md`)
- Token macro extension → System Groovy builder: evaluates as system script (evidence: `README.md`)
