Jenkins Installation and Configuration with Maven and GitHub
In this tutorial we install Jenkins and configure it to build a Maven project hosted on GitHub.
Note: This post has been updated for Jenkins 2.5x running on Java 21. The original 2014 version deployed Jenkins as a WAR inside Tomcat 7 on Java 7 and walked through a UI that has since changed substantially. Modern Jenkins is self-contained, so you no longer need a separate servlet container, and Git/Maven support now ships with the suggested plugins. The setup below is therefore shorter than it used to be.
Prerequisites
You need three things installed locally before starting:
- Java 21 (or 25). Current Jenkins LTS releases require Java 21 as a minimum; Java 17 was dropped in the April 2026 LTS line.
- Maven, to build the project.
- Git. On Windows, install Git for Windows and select the option that adds the git executables to your
PATH, so Jenkins can find them.
Installing Jenkins
Jenkins is distributed as a self-contained web application: a single WAR file you run directly, with no Tomcat or other servlet container required.
- Download the latest LTS
jenkins.warfrom the Jenkins download page. - Open a terminal and run
java -jar jenkins.war. - Jenkins starts on http://localhost:8080. On first launch it prints an initial admin password to the console (and writes it to
<JENKINS_HOME>/secrets/initialAdminPassword). Paste that into the Unlock Jenkins screen. - Choose Install suggested plugins. This bundle already includes the Git, GitHub, Maven Integration and Pipeline plugins, so there is nothing extra to install for this tutorial.
- Create the first admin user, and you land on the dashboard.
In 2014 you had to install the GitHub plugin by hand from the
Availableplugins tab. Today it comes with the suggested-plugins bundle, so that whole step is gone. If you ever do need it, plugins now live underManage Jenkins→Plugins.
Prefer containers? docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts gives you the same Jenkins instance.
Configuring JDK, Git and Maven
Jenkins can auto-install these tools for you, but pointing it at your existing local installations is faster and more predictable.
- Go to
Manage Jenkins→Tools. - In the JDK section click
Add JDK, uncheckInstall automatically, then set aName(e.g.jdk-21) andJAVA_HOME. - In the Git section click
Add Git, uncheckInstall automatically, then set aNameand thePath to Git executable. If git is on yourPATH, plaingit(orgit.exeon Windows) is enough. - In the Maven section click
Add Maven, uncheckInstall automatically, then set aName(e.g.maven-3) andMAVEN_HOME. - Click
Save.
These settings used to live under
Configure System. In current Jenkins they have their ownToolspage.
Building a GitHub project (Freestyle)
Let’s build a real public Maven project: Jenkins’s own sample app, jenkins-docs/simple-java-maven-app, a small “Hello world” with a couple of unit tests.
- From the dashboard click
New Item(this was calledNew Jobin older versions). - Enter a name, choose
Freestyle project, and clickOK. - In the
Source Code Managementsection selectGitand enter theRepository URL:https://github.com/jenkins-docs/simple-java-maven-app.git. A public repo needs no credentials; for a private one you would add credentials here. LeaveBranch Specifierat the repo default (*/masterfor this project). - In the
Build Stepssection chooseAdd build step→Invoke top-level Maven targets. Pick the Maven version you configured and enterclean packageinGoals.
If the pom.xml is not at the repository root, set its path under Advanced (for example subdir/pom.xml). The sample repo keeps it at the root, so you can skip that here.
- Click
Save, thenBuild Now. - A new build appears in the
Build Historypanel. Open it and selectConsole Outputto watch Jenkins clone the repository, resolve dependencies, run the tests and produce the JAR.
The old Git plugin had a
Skip internal tagoption to stop it tagging every build. That option is gone; modern Jenkins clones without tagging by default.
Going further: a Pipeline
Freestyle jobs are configured by clicking through the UI. The modern idiom is a Pipeline defined in code: a Jenkinsfile committed alongside your project, so the build definition is versioned with the source. The sample repo already ships one. To use it:
New Item→Pipeline.- Under the
Pipelinesection choosePipeline script from SCM, setSCMtoGit, use the same repository URL, and setScript PathtoJenkinsfile. Save, thenBuild Now.
A minimal Jenkinsfile for the same Maven build looks like this:
pipeline {
agent any
tools {
maven 'maven-3' // the name you set under Manage Jenkins → Tools
jdk 'jdk-21'
}
stages {
stage('Build') {
steps {
sh 'mvn -B clean package'
}
}
}
post {
success {
archiveArtifacts artifacts: 'target/*.jar', fingerprint: true
}
}
}
agent any runs the build on any available executor. The tools block pulls in the Maven and JDK installations you configured earlier. The Build stage runs the same clean package goals, and the post block archives the resulting JAR so you can download it from the build page. Because this file lives in the repository, every clone of your project carries its own build definition, which is the real advantage over a click-configured freestyle job. On Windows agents, use bat 'mvn -B clean package' instead of sh.
Conclusion
You installed Jenkins as a standalone application, pointed it at your local JDK, Git and Maven, and built a public GitHub Maven project both as a freestyle job and as a Pipeline. From here you can add a GitHub webhook (under Manage Jenkins → System) to trigger builds automatically on every push, or extend the Jenkinsfile with test and deploy stages.
The Disqus comment system is loading ...
If the message does not appear, please check your Disqus configuration.