Jenkins and Java

This site is the new docs site currently being tested. For the actual docs in use please go to https://www.jenkins.io/doc.

Jenkins supports building Java projects since its inception, and for a reason! It’s both the language Jenkins is written in, plus the language in use by many if not all the projects Kohsuke Kawaguchi wanted to watch out when he created the tool many years ago.

If you want to build a Java project, there are a bunch of different options. The most typical ones nowadays are generally Apache Maven, or Gradle.

Apache Maven

In any FreeStyle job, as currently Maven is supported in standard, you can use the dedicated step. One advantage is, as for all Jenkins tools, that you can select a specific Maven version and have Jenkins automatically install it on the build node it’s going to run on.

Jenkins Maven step

Gradle

As the associated plugin is not installed by default, first install the plugin:gradle[Gradle plugin]. Once done, you should be able to add a Gradle step.

Jenkins Gradle step
Java plugins for Jenkins
JUnit plugin

publishes JUnit XML formatted test reports for trending and analysis

Gradle plugin

support invoking Gradle as a build step and listing executing tasks per build

Warnings Next Generation plugin

collects compiler warnings and issues from static analysis tools such as SpotBugs and PMD

Cobertura plugin

publish and trend code coverage reports from Cobertura

SonarQube plugin

integrate reporting from the SonarQube code quality/inspection platform

Repository Connector plugin

adds features for resolving artifacts from a Maven repository such as Nexus or Artifactory.