First, what Maven is?
Maven is a project management and comprehension tool. Maven provides a developer to build a complete life cycle framework. Development teams can automate basic tool for building projects, Maven using the standard default directory structure and build lifecycle.
When multiple development team environment, Maven can set the standard configuration is completed in a very short period of time. Since the majority of the projects are simple, and can be reused, Maven make the developer's job easier and at the same time creating reports, inspection, build and test automation settings.
Second, the installation maven
Installation maven, the need for environmental support jdk job.
Most tutorials, jdk online and maven are compiled and installed, you need to set some environment variables. If you need to specify the version, you need to compile and install.
Here for quick installation, direct apt-get install.
Environment Description
operating system | ip | Roles |
ubuntu-16.04.4-server-amd64 | 192.168.10.122 | Jenkins |
Log on to the server Jenkins
Install open-jdk
apt-get install -y openjdk-8-jdk
View java version
root@ubuntu:~# java -version openjdk version "1.8.0_222" OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~16.04.1-b10) OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
Installation maven
apt-get install -y maven
To verify that Maven has been installed correctly, the print version of Maven:
root@ubuntu:~# mvn -version Apache Maven 3.3.9 Maven home: /usr/share/maven Java version: 1.8.0_222, vendor: Private Build Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre Default locale: zh_CN, platform encoding: UTF-8 OS name: "linux", version: "4.4.0-116-generic", arch: "amd64", family: "unix"
Note: Some tutorials say you want to modify the source to update maven Ali cloud.
But do not be freely modified, because some older versions of dependencies, Ali cloud is not.
Three, Jenkins configure maven
Add jdk
Log on to Jenkins management background, click Manage Jenkins -> Global Tool Configuration
Click Add jdk
Install automatically in front of the check, remove
Enter an alias and JAVA_HOME
Note: JAVA_HOME input box below, do not have warning or error message, otherwise the path is incorrect.
When using mvn -version command, it has been printed Java home variables Note: remove the last jre
Add maven
Click Add Maven
Install automatically in front of the check, remove
Enter the name and MAVEN_HOME
Note: Use mvn -version command, you can see the Maven home variables
MAVEN_HOME input box below, do not have warning or error message, otherwise the path is incorrect.
Click the Save button
Fourth, install Maven Integration plugin
Log jenkins background, click Manage Jenkins -> Manage Plugins
Search Keywords maven, find the plug-in Maven Integration, and check it
Click below to be installed directly
Wait a few minutes, you can install complete.
If you install Maven Integration failed javadoc.hpi need to manually download files, download specific path, an error message will be prompted, use Thunder download.
Then select Advanced mode in jenkins plug-in management, and then upload the installation can be solved!