What Build Tools Does Jenkins Use? Maven, Ant, and the Build Pipeline Explained
Jenkins is built and packaged with Apache Maven, which handles compilation, testing, and WAR assembly, while Apache Ant is embedded both as a library for executing user-defined build scripts and as a helper tool during the Maven build process itself.
The open-source automation server Jenkins—hosted in the jenkinsci/jenkins GitHub repository—relies on a specific combination of build tools to compile its source code and to support the wide variety of build jobs it can execute. Understanding what build tools Jenkins uses is essential for contributors packaging the jenkins.war file and for administrators configuring build agents.
Apache Maven: The Primary Build Tool
Jenkins uses Apache Maven as its sole build orchestration tool. The root pom.xml file defines a multi-module project that drives the entire software lifecycle, from compilation to final artifact assembly.
In pom.xml, Maven coordinates several critical phases:
- Compilation of Java source files across modules such as
core,war, andcli - Testing via Surefire and JUnit configurations defined in
test/pom.xml - Code generation using ANTLR for parsing tasks
- License checking to ensure compliance with dependency licenses
- Assembly of the final
jenkins.warfile via thewar/pom.xmlmodule
According to the jenkinsci/jenkins source code, no Gradle build files are present in the repository, confirming that Maven is the exclusive build tool for the project itself.
How Apache Ant Integrates with Jenkins
While Maven builds Jenkins itself, Apache Ant is integrated into the project in two distinct ways: as a runtime dependency for executing user builds, and as a build-time utility for ad-hoc scripting within the Maven lifecycle.
Ant as a Runtime Library for Build Execution
Jenkins embeds Ant as a library to support hudson.tasks.Ant, the class that enables Jenkins jobs to run Ant build scripts on agents.
In core/pom.xml (around line 240), the project declares a direct dependency on the Ant library:
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
</dependency>
This dependency allows Jenkins controllers to dispatch Ant-based builds to agents without requiring a separate Ant installation on every node.
Ant Tasks During the Maven Build
The Jenkins build process uses the maven-antrun-plugin to execute Ant tasks during specific Maven phases. In the root pom.xml (around line 420), the plugin is configured to run ad-hoc scripts for additional setup steps that are more easily expressed in Ant than in Maven's native plugin ecosystem.
This configuration appears within the build plugins section:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<target>
<!-- Example Ant task executed during Maven build -->
<echo message="Generating additional sources…" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Key Build Configuration Files
The repository structure separates build concerns across multiple Maven modules. Here are the critical files that define how Jenkins is constructed:
| Module Path | Purpose |
|---|---|
pom.xml (Root) |
Defines the overall Maven multi-module build, plugin management, and artifact assembly. |
core/pom.xml |
Declares Ant as a runtime dependency and contains core-specific compilation settings. |
war/pom.xml |
Packages the jenkins.war using Maven and configures the embedded Jetty/Winstone server. |
test/pom.xml |
Configures unit test execution (Surefire, JUnit) and includes the Ant library for test utilities. |
cli/pom.xml |
Builds the command-line client; also depends on the Ant library for scriptable actions. |
bom/pom.xml |
Generates the Maven Bill-of-Materials (BOM) for centralized dependency management. |
Building Jenkins from Source
To build Jenkins locally using the Maven tool set, run the following command from the repository root:
# Fast build that skips tests
mvn clean install -DskipTests
This command compiles all modules, executes the ANTLR code generation, runs license checks, and assembles the final jenkins.war in the war/target/ directory.
Executing Ant Builds in Jenkins Pipelines
Because Jenkins includes Ant as a runtime library, you can execute Ant-based builds directly from Pipeline scripts without installing Ant on the agent. The ant step invokes the embedded Ant engine:
pipeline {
agent any
stages {
stage('Ant Build') {
steps {
ant targets: 'clean compile', buildFile: 'build.xml'
}
}
}
}
This pipeline stage uses the hudson.tasks.Ant implementation internally, leveraging the same org.apache.ant:ant dependency declared in core/pom.xml.
Summary
- Apache Maven is the exclusive build tool used to compile, test, and package Jenkins itself, orchestrated from the root
pom.xml. - Apache Ant is embedded as a runtime dependency in
core/pom.xmlto support user-defined Ant builds viahudson.tasks.Ant. - The maven-antrun-plugin executes Ant scripts during the Maven build lifecycle for setup tasks, configured in the root
pom.xmlaround line 420. - No Gradle build files exist in the repository; the project relies entirely on the Maven + Ant combination.
Frequently Asked Questions
Does Jenkins use Gradle to build itself?
No. According to the source code analysis of the jenkinsci/jenkins repository, no Gradle build files are present. The project relies exclusively on Apache Maven as defined in the root pom.xml and its submodules.
What is the Maven AntRun plugin used for in Jenkins?
The maven-antrun-plugin (defined around line 420 in the root pom.xml) executes ad-hoc Ant scripts during specific Maven phases, such as generate-sources. This allows the build to perform complex file manipulations or custom setup steps that are not easily handled by standard Maven plugins.
How can I build the Jenkins WAR file locally?
Run mvn clean install from the repository root. To skip unit tests for faster builds, use mvn clean install -DskipTests. The assembled jenkins.war file will be located in war/target/.
Why does Jenkins depend on Ant libraries if it uses Maven?
Jenkins declares org.apache.ant:ant as a dependency in core/pom.xml to support the hudson.tasks.Ant functionality. This allows Jenkins controllers to execute Ant-based build jobs on agents using the embedded Ant runtime, rather than requiring a separate Ant installation on every build node.
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 →