Preparing for Plugin Development

Download and install a JDK

Jenkins is based on Java, and to build Jenkins plugins, you need to install a Java Development Kit, or JDK. Recent Jenkins releases require JDK 8 to run, so that’s what we’re using here.

Download JDK 8 for free from the Oracle website and install it.

Many Linux distributions provide packages for Oracle JDK or OpenJDK JDK for an easier install and upgrade experience. Consult your distribution’s documentation for details. It may even be installed already. To find out, type javac -version on a command prompt.

Download and install Maven

Jenkins plugins overwhelmingly use Maven to build, so that’s what we’re going to use in this tutorial.

Download Maven from its website. Make sure to download one of the files with bin in their name. src indicates a source distribution.

Many Linux distributions provide packages for Maven for an easier install and upgrade experience. Consult your distribution’s documentation for details. On macOS, the Homebrew package manager offers Maven packages. Make sure a recent version of Maven 3, ideally 3.3.9 or newer, is provided if you decide to go this route.

Download and extract Maven, and note its location. You now have the following options:

  1. Add the bin/ subdirectory of the extracted directory to your PATH. This will let you invoke Maven using mvn. How this works is dependent on your OS and command shell.

  2. Always use the full path to the mvn executable, for example ~/Applications/apache-maven/bin/mvn or C:\Program files\Maven\bin\mvn

The rest of the tutorial assumes that Maven is on your PATH, but you can also just type the full path.

Once downloaded and extracted somewhere, let’s make sure everything works as expected by typing the following in a command prompt:

This is Terminal.app on macOS, cmd.exe on Windows, and any shell on Linux.
mvn -version

This prints some diagnostic output, including the versions of Java and Maven, and which Java installation was found by Maven. This should indicate a 1.8 version of Java, and list the path to the JDK. If either of these is not the case, see Troubleshooting.

Troubleshooting

Anything not working for you? Ask for help in IRC or on the jenkinsci-dev mailing list.

References