What Are the Dependencies for Jenkins Development? A Complete Maven Guide
Jenkins development requires a Maven-based Java dependency stack defined across modular POM files, including core runtime libraries in core/pom.xml, testing frameworks in test/pom.xml, and the plugin parent POM for extension authors.
Jenkins is a large-scale, modular Java application built with Apache Maven. All compile-time, test-time, and runtime libraries are declared in the pom.xml files across the jenkinsci/jenkins repository. Understanding these dependencies is essential for core contributions, plugin development, and custom workflow implementation.
Core Runtime Dependencies
The foundational libraries required to build and run Jenkins are declared in core/pom.xml and war/pom.xml. These modules define the servlet container, logging, and utility libraries that power the Jenkins master.
Servlet Container and Web Layer
Jenkins embeds Jetty 12 as its servlet container. In core/pom.xml, you will find dependencies on org.eclipse.jetty.ee9:jetty-server and org.eclipse.jetty.ee9:jetty-servlet. The servlet API is provided by jakarta.servlet:jakarta.servlet-api, ensuring compatibility with Jakarta EE specifications.
Core Utilities
The core module relies on Google Guava (com.google.guava:guava) for collections and caching utilities. Logging is handled through SLF4J (org.slf4j:slf4j-api), while command-line parsing uses org.kohsuke:args. The war/pom.xml aggregates these into the deployable web application archive alongside org.jenkins-ci.main:jenkins-war.
Plugin Development Dependencies
Plugins inherit from the plugin parent POM (org.jenkins-ci.plugins:plugin) declared in the root pom.xml. This parent manages versions for core APIs and common plugin dependencies.
Key dependencies for plugin authors include:
- Jenkins Core API:
org.jenkins-ci.main:jenkins-core(scope: provided) - Workflow Support:
org.jenkins-ci.main:workflow-step-apifor Pipeline steps - Authentication:
org.jenkins-ci.main:matrix-authfor security utilities
Using the provided scope for jenkins-core ensures the plugin uses the classes available at runtime without bundling them into the plugin HPI file. Optional integrations like SSH support (mina-sshd-api) or GitHub connectivity (github-api) are available as separate plugin dependencies.
Testing Dependencies
The test/pom.xml module declares the complete testing stack for integration and unit tests. This centralized approach ensures consistent test behavior across all Jenkins modules.
The testing dependencies include:
- JUnit 5:
org.junit.jupiter:junit-jupiter-apiandjunit-jupiter-engine - Mocking:
org.mockito:mockito-corefor test doubles - Async Testing:
org.awaitility:awaitilityfor asynchronous condition polling - Coverage:
org.jacoco:jacoco-maven-pluginandorg.jacoco:org.jacoco.corefor code coverage reporting
These dependencies use the test scope and are inherited by modules running integration tests against the Jenkins core runtime.
WebSocket and CLI Dependencies
Modern Jenkins features require specialized transport layers for real-time communication and remote administration.
WebSocket Support
The websocket/spi/pom.xml defines the abstract API (org.jenkins-ci.main:jenkins-websocket), while websocket/jetty12-ee9/pom.xml provides the concrete implementation using org.eclipse.jetty.ee9:jetty-websocket-jetty12. This separation allows Jenkins to support WebSocket connections for real-time build log streaming.
Command Line Interface
The CLI module in cli/pom.xml declares org.jenkins-ci.main:jenkins-cli along with org.kohsuke:metainf-services for service-loader utilities. These enable the Jenkins CLI client to communicate with the server over HTTP or WebSocket transports.
Build and Plugin Management
The root pom.xml manages the build lifecycle through standard Maven plugins and dependency versions. All modules inherit Java 11+ compatibility settings from this parent.
Key build dependencies include:
- Compiler:
org.apache.maven.plugins:maven-compiler-pluginenforces Java 11+ source compatibility - Testing:
org.apache.maven.plugins:maven-surefire-pluginexecutes JUnit 5 tests - Packaging:
org.apache.maven.plugins:maven-jar-pluginandmaven-resources-pluginhandle artifact creation
All artifacts resolve from the https://repo.jenkins-ci.org/public/ repository defined in the root POM.
How to Declare Dependencies in a Jenkins Plugin
When developing a plugin, inherit from the Jenkins plugin parent and declare core dependencies as provided:
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>5.52</version>
</parent>
<artifactId>my-awesome-plugin</artifactId>
<dependencies>
<!-- Core Jenkins API (provided at runtime) -->
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-core</artifactId>
<scope>provided</scope>
</dependency>
<!-- Test helpers -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Access core classes in your Java source to interact with the Jenkins instance:
import hudson.model.Result;
import jenkins.model.Jenkins;
public class ExampleUtil {
public static boolean isRunningInJenkins() {
return Jenkins.get() != null;
}
public static String getResultName(Result r) {
return r.toString();
}
}
Summary
- Core runtime: Declared in
core/pom.xmlandwar/pom.xml, including Jetty 12, Jakarta Servlet API, Guava, and SLF4J. - Plugin development: Uses the parent POM from
org.jenkins-ci.plugins:plugin, treatingjenkins-coreas a provided dependency. - Testing stack: Defined in
test/pom.xmlwith JUnit 5, Mockito, Awaitility, and JaCoCo for comprehensive coverage. - WebSocket/CLI: Modular dependencies in
websocket/spi/pom.xml,websocket/jetty12-ee9/pom.xml, andcli/pom.xmlenable real-time features and remote access. - Build tools: Standard Maven plugins in the root POM manage compilation and packaging for Java 11+.
Frequently Asked Questions
What build tool does Jenkins use for dependency management?
Jenkins uses Apache Maven with a multi-module project structure. The root pom.xml acts as the parent, and all modules—including core, war, test, and cli—inherit common dependency versions and plugin configurations from it.
How do I add a dependency to a Jenkins plugin?
Declare the dependency in your plugin's pom.xml with the appropriate scope. Use provided for anything included in Jenkins core (like jenkins-core), compile for libraries you need to bundle, and test for testing frameworks. Inherit from org.jenkins-ci.plugins:plugin to ensure version alignment with the Jenkins ecosystem.
Where are the test dependencies defined in the Jenkins source?
Testing dependencies are centralized in the test/pom.xml module. This file declares JUnit 5, Mockito, Awaitility, and JaCoCo. Modules that run integration tests depend on this artifact to receive the complete testing classpath.
What Java version is required for Jenkins development?
According to the root POM configuration, Jenkins currently requires Java 11 or newer for compilation and runtime. The maven-compiler-plugin in the root pom.xml enforces this compatibility level.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →