Jenkins plugins mostly use Maven to build, so that’s what we’re going to use in this tutorial.
Download Maven from Apache Maven website.
Make sure to download one of the binary archives (with bin
in their name).
|
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.8.3 or newer, is provided if you decide to go this route.
|
Next you will need to extract Maven, and take note of its location. When you extract the Maven files, make sure you extract them directly into the target directory (e.g. extract straight into C:\Program Files (x86)\Maven ) - do not extract the files to a different location then copy the files.
Then, add the full path of the bin/
subdirectory extracted (for example, ~/Applications/apache-maven/bin
or C:\Program files\Maven\bin
) to the PATH
variable in your OS.
This will let you invoke Maven using mvn
.
The rest of the tutorial assumes that Maven is on your PATH
environment variable.
Add the following to your ~/.m2/settings.xml
(Windows users will find them in %USERPROFILE%\.m2\settings.xml
):
<settings>
<profiles>
<profile>
<id>jenkins</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
To verify that Maven is installed, run the following command:
This command prints some diagnostic output, including the versions of Java and Maven, and which Java installation was found by Maven.
It should indicate a 17 version of Java, and list the path to where Java is located.
If you don’t see this information, see Troubleshooting.