# How to Build Jenkins from Source: A Complete Maven Guide

> Learn to build Jenkins from source with Java JDK 21+ and Maven 3.9.6+. Generate the Jenkins WAR file using a simple Maven command for easy deployment and testing.

- Repository: [Jenkins/jenkins](https://github.com/jenkinsci/jenkins)
- Tags: how-to-guide
- Published: 2026-07-29

---

**Building Jenkins from source requires Apache Maven 3.9.6+ and JDK 21 (or 25), followed by running `mvn -am -pl war,bom -Pquick-build clean install` to generate the WAR file at `war/target/jenkins.war`, which you can launch directly or run via the Maven Jetty plugin.**

Compiling Jenkins from source allows contributors to test patches, debug issues, or customize the automation server. The jenkinsci/jenkins repository is organized as a multi-module Maven project where the parent POM coordinates dependencies and plugin versions, while the dedicated `war` module assembles the final web application archive. This guide walks through the complete build process using the actual Maven configurations found in the repository.

## Prerequisites for Building Jenkins from Source

Before compiling, ensure your environment matches the requirements specified in the project's [CONTRIBUTING.md](https://github.com/jenkinsci/jenkins/blob/master/CONTRIBUTING.md) and validated by the root [Jenkinsfile](https://github.com/jenkinsci/jenkins/blob/master/Jenkinsfile):

- **JDK 21 or 25** (LTS versions recommended; tested in CI)
- **Apache Maven 3.9.6+** (the build uses specific plugin versions locked in the parent POM)
- **Git** for cloning the repository
- **Node.js and Yarn** (optional, only required if modifying frontend assets)

## Clone the Jenkins Repository

Start by cloning the official repository and entering the project directory:

```bash
git clone https://github.com/jenkinsci/jenkins.git
cd jenkins

```

The repository contains the parent POM ([`pom.xml`](https://github.com/jenkinsci/jenkins/blob/main/pom.xml)), the `core/` module with the main application code, the `war/` module that packages the WAR, and the `Jenkinsfile` defining the continuous integration pipeline.

## Building the Jenkins WAR with Maven

### Understanding the Maven Module Structure

The build is driven by Maven's multi-module configuration. The **parent POM** ([`pom.xml`](https://github.com/jenkinsci/jenkins/blob/main/pom.xml) at the repository root) defines dependency management and plugin versions for all sub-modules. The **[[`war/pom.xml`](https://github.com/jenkinsci/jenkins/blob/main/war/pom.xml)](https://github.com/jenkinsci/jenkins/blob/master/war/pom.xml)** specifically configures the `maven-hpi-plugin` (version 3.24) for Jenkins-specific packaging and the `maven-assembly-plugin` (version 3.5.0) to bundle web resources. The `war` module depends on the `core` module and the `bom` (Bill of Materials), which is why the build command targets these specifically.

### Quick Build Command (Skip Tests)

For rapid iteration when you only need the WAR file without running the test suite, use the `quick-build` profile:

```bash
mvn -am -pl war,bom -Pquick-build clean install

```

The `-am` (also-make) flag ensures Maven builds all dependencies of the `war` and `bom` modules first. The `-Pquick-build` profile skips tests and disables unnecessary checks, producing the artifact in approximately 2-5 minutes depending on your hardware.

### Full Build with Tests

To validate changes completely as the CI pipeline does, run the default Maven lifecycle which executes unit and functional tests:

```bash
mvn clean install

```

For lighter test coverage during development, use specific test profiles defined in the build configuration:

```bash

# Unit tests only

mvn -Plight-test clean install

# Unit tests plus smoke tests

mvn -Psmoke-test clean install

```

The resulting **WAR file** is located at `war/target/jenkins.war` and contains the full Jenkins web application ready for deployment.

## Running Jenkins Locally from Source

### Launch the WAR Directly

Once the build completes, launch Jenkins directly from the command line using the executable WAR:

```bash
java -jar war/target/jenkins.war --httpPort=8080

```

Jenkins will start on port 8080 and write configuration files to `~/.jenkins/` by default.

### Run with Maven Jetty Plugin

For development workflows requiring hot-reloading or debugging, run Jenkins directly from the Maven module using the Jetty plugin. Set the required JVM options to open internal modules (necessary for Java 17+), then execute:

```bash
export MAVEN_OPTS='--add-opens java.base/java.lang=ALL-UNNAMED \
  --add-opens java.base/java.io=ALL-UNNAMED \
  --add-opens java.base/java.util=ALL-UNNAMED'

mvn -pl war jetty:run

```

This command starts Jenkins from the compiled source without manually handling the WAR file, automatically reloading classes when you recompile.

## Building Frontend Assets (Optional)

If modifying JavaScript or CSS components, you must build the frontend assets separately using Yarn. The build process is documented in [CONTRIBUTING.md](https://github.com/jenkinsci/jenkins/blob/master/CONTRIBUTING.md):

```bash

# Enable Corepack for Yarn

corepack enable
export PATH=$PWD/node:$PWD/node/node_modules/corepack/shims:$PATH

# Install dependencies and build

yarn
yarn start

```

The `yarn start` command launches a development server on `http://localhost:3000` that proxies to your local Jenkins instance, enabling live reloading of UI changes.

## Understanding the CI Build Pipeline

The repository's [`Jenkinsfile`](https://github.com/jenkinsci/jenkins/blob/master/Jenkinsfile) provides authoritative documentation of the official build process. It defines a matrix build running on Linux and Windows with JDK 21 and JDK 25, executing the same Maven commands described above. The pipeline archives the `jenkins.war` artifact and records test results, validating that any local build following these steps produces a binary identical to the official releases.

## Summary

- **Clone** the repository from `https://github.com/jenkinsci/jenkins.git`
- **Build** the WAR using `mvn -am -pl war,bom -Pquick-build clean install` for speed, or `mvn clean install` for complete validation
- **Locate** the output at `war/target/jenkins.war` generated by the `war` module's configuration in [[`war/pom.xml`](https://github.com/jenkinsci/jenkins/blob/main/war/pom.xml)](https://github.com/jenkinsci/jenkins/blob/master/war/pom.xml)
- **Run** the WAR directly with `java -jar` or use `mvn -pl war jetty:run` for development
- **Test** changes using profiles like `-Plight-test` or `-Psmoke-test` before submitting contributions

## Frequently Asked Questions

### What Java version is required to build Jenkins from source?

You need **JDK 21 or JDK 25** to compile the current master branch. The project's [Jenkinsfile](https://github.com/jenkinsci/jenkins/blob/master/Jenkinsfile) tests builds against these specific versions on both Linux and Windows. While Jenkins can run on Java 17, the source build currently targets newer LTS releases for development.

### Where is the WAR file located after building from source?

After a successful Maven build, the `jenkins.war` file is located at **`war/target/jenkins.war`** relative to the repository root. This path is defined by the `maven-hpi-plugin` configuration in [[`war/pom.xml`](https://github.com/jenkinsci/jenkins/blob/main/war/pom.xml)](https://github.com/jenkinsci/jenkins/blob/master/war/pom.xml), which packages the core classes and web resources into the final archive.

### How do I skip tests when building Jenkins?

Append the `-Pquick-build` Maven profile to your command: `mvn -am -pl war,bom -Pquick-build clean install`. This profile disables test execution and skips additional verification steps, reducing build time significantly while still producing a functional WAR file for local testing.

### Can I run Jenkins from source without building the WAR file first?

Yes, you can run directly from the Maven source using the Jetty plugin. Execute `mvn -pl war jetty:run` after setting the appropriate `MAVEN_OPTS` to open Java modules. This approach is ideal for development because it eliminates the need to manually rebuild and deploy the WAR after each code change.